From 03fe699544eaf2480863bef0a666df5633651716 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Tue, 15 Feb 2011 13:55:00 -0300 Subject: Added a test to numpy scalar type being accepted as Python scalar. --- tests/samplebinding/numpy_test.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/samplebinding/numpy_test.py (limited to 'tests') diff --git a/tests/samplebinding/numpy_test.py b/tests/samplebinding/numpy_test.py new file mode 100644 index 000000000..e422a9982 --- /dev/null +++ b/tests/samplebinding/numpy_test.py @@ -0,0 +1,30 @@ +import sys + +try: + from distutils import sysconfig + if bool(sysconfig.get_config_var('Py_DEBUG')): + sys.exit(0) + import numpy +except: + sys.exit(0) + +import unittest +from sample import PointF + +class TestNumpyTypes(unittest.TestCase): + + def testNumpyConverted(self): + x, y = (0.1, 0.2) + p = PointF(float(numpy.float32(x)), float(numpy.float32(y))) + self.assertAlmostEqual(p.x(), x) + self.assertAlmostEqual(p.y(), y) + + def testNumpyAsIs(self): + x, y = (0.1, 0.2) + p = PointF(numpy.float32(x), numpy.float32(y)) + self.assertAlmostEqual(p.x(), x) + self.assertAlmostEqual(p.y(), y) + +if __name__ == "__main__": + unittest.main() + -- cgit v1.2.3