Skip to content
Snippets Groups Projects
Commit b94de272 authored by Cyril Moineau's avatar Cyril Moineau
Browse files

Update integer conversion test to fix issue with int64.

parent c7e702f6
No related branches found
No related tags found
1 merge request!31Adding INT64 Tensor support
...@@ -16,7 +16,7 @@ class test_tensor(unittest.TestCase): ...@@ -16,7 +16,7 @@ class test_tensor(unittest.TestCase):
self.assertTrue("cpu" in aidge_core.Tensor.get_available_backends()) self.assertTrue("cpu" in aidge_core.Tensor.get_available_backends())
def test_numpy_int_to_tensor(self): def test_numpy_int_to_tensor(self):
np_array = np.arange(9).reshape(1,1,3,3) np_array = np.arange(9).reshape(1,1,3,3).astype(np.int32)
# Numpy -> Tensor # Numpy -> Tensor
t = aidge_core.Tensor(np_array) t = aidge_core.Tensor(np_array)
self.assertEqual(t.dtype(), aidge_core.DataType.Int32) self.assertEqual(t.dtype(), aidge_core.DataType.Int32)
...@@ -35,6 +35,16 @@ class test_tensor(unittest.TestCase): ...@@ -35,6 +35,16 @@ class test_tensor(unittest.TestCase):
for i,j in zip(t.dims(), nnarray.shape): for i,j in zip(t.dims(), nnarray.shape):
self.assertEqual(i,j) self.assertEqual(i,j)
def test_numpy_int64_to_tensor(self):
np_array = np.arange(9).reshape(1,1,3,3).astype(np.int64)
# Numpy -> Tensor
t = aidge_core.Tensor(np_array)
self.assertEqual(t.dtype(), aidge_core.DataType.Int64)
for i_t, i_n in zip(t, np_array.flatten()):
self.assertTrue(i_t == i_n)
for i,j in zip(t.dims(), np_array.shape):
self.assertEqual(i,j)
def test_numpy_float_to_tensor(self): def test_numpy_float_to_tensor(self):
t = aidge_core.Tensor() t = aidge_core.Tensor()
np_array = np.random.rand(1, 1, 3, 3).astype(np.float32) np_array = np.random.rand(1, 1, 3, 3).astype(np.float32)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment