diff --git a/modules/gfx/pymod/export_primlist.cc b/modules/gfx/pymod/export_primlist.cc index f4c7fddd83fe37909a5b91d9846503768e89da5e..5dd3a5b7d7a9f9f02be9a5ee84f9ab5b25844a2c 100644 --- a/modules/gfx/pymod/export_primlist.cc +++ b/modules/gfx/pymod/export_primlist.cc @@ -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); diff --git a/modules/gfx/tests/test_gfx.py b/modules/gfx/tests/test_gfx.py index ffca3b507ebbc6dfc8fe3d50c1701af75d0f0574..fcd0f8510660904a4f07459fa4f28c6391b8489d 100644 --- a/modules/gfx/tests/test_gfx.py +++ b/modules/gfx/tests/test_gfx.py @@ -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__':