Skip to content
Snippets Groups Projects
Commit 1c98faec authored by Xavier Robin's avatar Xavier Robin
Browse files

fix: properly test for input array types

parent da26908d
Branches
Tags
No related merge requests found
......@@ -41,7 +41,7 @@ namespace {
if(!PyArray_ISCONTIGUOUS(va)) {
throw Error("expected vertex array to be contiguous");
}
if(!PyArray_TYPE(va)==NPY_FLOAT) {
if(PyArray_TYPE(va)!=NPY_FLOAT) {
throw Error("expected vertex array to be of dtype=float32");
}
size_t v_size=PyArray_SIZE(va);
......@@ -60,7 +60,7 @@ namespace {
if(!PyArray_ISCONTIGUOUS(na)) {
throw Error("expected normal array to be contiguous");
}
if(!PyArray_TYPE(na)==NPY_FLOAT) {
if(PyArray_TYPE(na)!=NPY_FLOAT) {
throw Error("expected normal array to be of dtype=float32");
}
if((size_t)PyArray_SIZE(na)!=v_size) {
......@@ -76,7 +76,7 @@ namespace {
if(!PyArray_ISCONTIGUOUS(ca)) {
throw Error("expected color array to be contiguous");
}
if(!PyArray_TYPE(ca)==NPY_FLOAT) {
if(PyArray_TYPE(ca)!=NPY_FLOAT) {
throw Error("expected color array to be of dtype=float32");
}
if((size_t)PyArray_SIZE(ca)!=v_count*4) {
......@@ -91,7 +91,7 @@ namespace {
if(!PyArray_ISCONTIGUOUS(ia)) {
throw Error("expected vertex array to be contiguous");
}
if(!PyArray_TYPE(ia)==NPY_UINT) {
if(PyArray_TYPE(ia)!=NPY_UINT) {
throw Error("expected vertex array to be of dtype=uint32");
}
size_t i_size=PyArray_SIZE(ia);
......
......@@ -129,6 +129,28 @@ class TestGfx(unittest.TestCase):
None,
None,
numpy.zeros((4,3),dtype=numpy.uint32))
# Passing wrong data type should fail
with self.assertRaises(Exception):
pl.AddMesh(numpy.zeros((5, 3), dtype=numpy.uint32),
numpy.zeros((5, 3), dtype=numpy.float32),
numpy.zeros((5, 4), dtype=numpy.float32),
numpy.zeros((2, 3), dtype=numpy.uint32))
with self.assertRaises(Exception):
pl.AddMesh(numpy.zeros((5, 3), dtype=numpy.float32),
numpy.zeros((5, 3), dtype=numpy.uint32),
numpy.zeros((5, 4), dtype=numpy.float32),
numpy.zeros((2, 3), dtype=numpy.uint32))
with self.assertRaises(Exception):
pl.AddMesh(numpy.zeros((5, 3), dtype=numpy.float32),
numpy.zeros((5, 3), dtype=numpy.float32),
numpy.zeros((5, 4), dtype=numpy.uint32),
numpy.zeros((2, 3), dtype=numpy.uint32))
with self.assertRaises(Exception):
pl.AddMesh(numpy.zeros((5, 3), dtype=numpy.float32),
numpy.zeros((5, 3), dtype=numpy.float32),
numpy.zeros((5, 4), dtype=numpy.float32),
numpy.zeros((2, 3), dtype=numpy.float32))
if __name__== '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment