Example #1
0
 def test_dynamicTypeChange(self):
     print('TestSimpleArray: dynamicTypeChange')
     arr, rs = self.createNumpy('int32')
     name = "lala"
     a = SimpleArray(dtype='float32', name=name)
     fnames = ["a", "b", "c", "d", "e", "f"]
     a.setFeatureNames(fnames)
     a.createFromNumpy(arr, rs)
     self.assertTrue(a.featureNames() == fnames)
     self.assertTrue(a.name() == name)
Example #2
0
    def test_createFromNumpyInt(self):
        print('TestSimpleArray: createFromNumpyInt')

        arr, rs = self.createNumpy('int32')

        a = SimpleArray(dtype='int32')
        a.createFromNumpy(arr, rs)

        narr, nrs = a.copyToNumpy()
        diff = np.max(np.abs(narr - arr))
        diff += np.max(np.abs(nrs - rs))
        self.assertTrue(diff < 0.000001)
Example #3
0
    def test_equal(self):
        print('TestSimpleArray: equal')
        arr, rs = self.createNumpy('float32')

        a = SimpleArray()
        a.createFromNumpy(arr, rs)

        b = SimpleArray()
        b.createFromNumpy(arr, rs)

        self.assertEqual(a, b)

        b = a.copy()
        self.assertEqual(a, b)

        b.setFeatureNames(["a", "b", "c", "d", "e", "f"])
        self.assertNotEqual(a, b)