File: numpy_test.py

package info (click to toggle)
shiboken 1.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 6,012 kB
  • sloc: cpp: 50,315; python: 5,747; xml: 2,268; makefile: 137; ansic: 132
file content (30 lines) | stat: -rw-r--r-- 704 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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()