示例#1
0
 def test_dtype_change(self):
     concrete_array = np.array([True, False])
     lazy_array = as_lazy_data(concrete_array)
     wrapped = lazy_elementwise(lazy_array, _test_elementwise_op)
     self.assertTrue(is_lazy_data(wrapped))
     self.assertEqual(wrapped.dtype, np.int)
     self.assertEqual(wrapped.compute().dtype, wrapped.dtype)
示例#2
0
 def test_dtype_same(self):
     concrete_array = np.array([3.0], dtype=np.float16)
     lazy_array = as_lazy_data(concrete_array)
     wrapped = lazy_elementwise(lazy_array, _test_elementwise_op)
     self.assertTrue(is_lazy_data(wrapped))
     self.assertEqual(wrapped.dtype, np.float16)
     self.assertEqual(wrapped.compute().dtype, np.float16)
示例#3
0
 def test_basic(self):
     concrete_array = np.arange(30).reshape((2, 5, 3))
     lazy_array = as_lazy_data(concrete_array)
     wrapped = lazy_elementwise(lazy_array, _test_elementwise_op)
     self.assertTrue(is_lazy_data(wrapped))
     self.assertArrayAllClose(wrapped.compute(),
                              _test_elementwise_op(concrete_array))
示例#4
0
 def test_dtype_change(self):
     concrete_array = np.array([True, False])
     lazy_array = as_lazy_data(concrete_array)
     wrapped = lazy_elementwise(lazy_array, _test_elementwise_op)
     self.assertTrue(is_lazy_data(wrapped))
     self.assertEqual(wrapped.dtype, np.int)
     self.assertEqual(wrapped.compute().dtype, wrapped.dtype)
示例#5
0
 def test_dtype_same(self):
     concrete_array = np.array([3.], dtype=np.float16)
     lazy_array = as_lazy_data(concrete_array)
     wrapped = lazy_elementwise(lazy_array, _test_elementwise_op)
     self.assertTrue(is_lazy_data(wrapped))
     self.assertEqual(wrapped.dtype, np.float16)
     self.assertEqual(wrapped.compute().dtype, np.float16)
示例#6
0
 def test_basic(self):
     concrete_array = np.arange(30).reshape((2, 5, 3))
     lazy_array = as_lazy_data(concrete_array)
     wrapped = lazy_elementwise(lazy_array, _test_elementwise_op)
     self.assertTrue(is_lazy_data(wrapped))
     self.assertArrayAllClose(wrapped.compute(),
                              _test_elementwise_op(concrete_array))