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)
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)
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))
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)