diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-02-15 13:55:00 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:13:55 -0300 |
commit | 03fe699544eaf2480863bef0a666df5633651716 (patch) | |
tree | c25ad5fcd0c64164924a05cbc7c5e7dc4ade1f9d /tests | |
parent | d829150a965b004767458915569f93ecba915b06 (diff) |
Added a test to numpy scalar type being accepted as Python scalar.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/samplebinding/numpy_test.py | 30 |
1 files changed, 30 insertions, 0 deletions
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() + |