Ejemplo n.º 1
0
 def test_zero_ndim_lazy_to_scalar_1d_real_promote(self):
     real_array = np.array([456])
     dm = DataManager(as_lazy_data(np.array(123)))
     self.assertTrue(dm.has_lazy_data())
     dm.data = real_array
     self.assertFalse(dm.has_lazy_data())
     self.assertArrayEqual(dm.data, real_array)
Ejemplo n.º 2
0
 def test_zero_ndim_lazy_with_zero_ndim_lazy(self):
     lazy_array = as_lazy_data(np.array(456))
     dm = DataManager(as_lazy_data(np.array(123)))
     self.assertTrue(dm.has_lazy_data())
     dm.data = lazy_array
     self.assertTrue(dm.has_lazy_data())
     self.assertArrayEqual(dm.data, lazy_array.compute())
Ejemplo n.º 3
0
 def test_zero_ndim_lazy_to_scalar_1d_lazy_promote(self):
     lazy_array = as_lazy_data(np.array([456]))
     dm = DataManager(as_lazy_data(np.array(123)))
     self.assertTrue(dm.has_lazy_data())
     dm.data = lazy_array
     self.assertTrue(dm.has_lazy_data())
     self.assertArrayEqual(dm.data, lazy_array.compute())
Ejemplo n.º 4
0
 def test_zero_ndim_lazy_with_zero_ndim_real(self):
     real_array = np.array(456)
     dm = DataManager(as_lazy_data(np.array(123)))
     self.assertTrue(dm.has_lazy_data())
     dm.data = real_array
     self.assertFalse(dm.has_lazy_data())
     self.assertArrayEqual(dm.data, real_array)
Ejemplo n.º 5
0
 def test_zero_ndim_real_with_scalar_float(self):
     value = 456.0
     dm = DataManager(np.array(123))
     self.assertFalse(dm.has_lazy_data())
     dm.data = value
     self.assertFalse(dm.has_lazy_data())
     self.assertArrayEqual(dm.data, np.array(value))
Ejemplo n.º 6
0
 def test_zero_ndim_lazy_with_zero_ndim_real(self):
     real_array = np.array(456)
     dm = DataManager(as_lazy_data(np.array(123)))
     self.assertTrue(dm.has_lazy_data())
     dm.data = real_array
     self.assertFalse(dm.has_lazy_data())
     self.assertArrayEqual(dm.data, real_array)
Ejemplo n.º 7
0
 def test_zero_ndim_lazy_with_zero_ndim_lazy(self):
     lazy_array = as_lazy_data(np.array(456))
     dm = DataManager(as_lazy_data(np.array(123)))
     self.assertTrue(dm.has_lazy_data())
     dm.data = lazy_array
     self.assertTrue(dm.has_lazy_data())
     self.assertArrayEqual(dm.data, lazy_array.compute())
Ejemplo n.º 8
0
 def test_zero_ndim_lazy_to_scalar_1d_lazy_promote(self):
     lazy_array = as_lazy_data(np.array([456]))
     dm = DataManager(as_lazy_data(np.array(123)))
     self.assertTrue(dm.has_lazy_data())
     dm.data = lazy_array
     self.assertTrue(dm.has_lazy_data())
     self.assertArrayEqual(dm.data, lazy_array.compute())
Ejemplo n.º 9
0
 def test_zero_ndim_lazy_to_scalar_1d_real_promote(self):
     real_array = np.array([456])
     dm = DataManager(as_lazy_data(np.array(123)))
     self.assertTrue(dm.has_lazy_data())
     dm.data = real_array
     self.assertFalse(dm.has_lazy_data())
     self.assertArrayEqual(dm.data, real_array)
Ejemplo n.º 10
0
 def test_real_with_real(self):
     dm = DataManager(self.real_array * 10)
     self.assertFalse(dm.has_lazy_data())
     dm.replace(self.real_array)
     self.assertFalse(dm.has_lazy_data())
     self.assertIs(dm._real_array, self.real_array)
     self.assertIs(dm.data, self.real_array)
Ejemplo n.º 11
0
 def test_with_real_array(self):
     dm = DataManager(self.real_array)
     self.assertFalse(dm.has_lazy_data())
     result = dm.lazy_data()
     self.assertFalse(dm.has_lazy_data())
     self.assertEqual(result, self.lazy_array)
     self.assertFalse(dm.has_lazy_data())
Ejemplo n.º 12
0
 def test_with_real_array(self):
     dm = DataManager(self.real_array)
     self.assertFalse(dm.has_lazy_data())
     result = dm.lazy_data()
     self.assertFalse(dm.has_lazy_data())
     self.assertEqual(result, self.lazy_array)
     self.assertFalse(dm.has_lazy_data())
Ejemplo n.º 13
0
 def test_zero_ndim_real_with_scalar_float(self):
     value = 456.0
     dm = DataManager(np.array(123))
     self.assertFalse(dm.has_lazy_data())
     dm.data = value
     self.assertFalse(dm.has_lazy_data())
     self.assertArrayEqual(dm.data, np.array(value))
Ejemplo n.º 14
0
 def test_lazy_with_real(self):
     lazy_array = as_lazy_data(self.real_array)
     dm = DataManager(lazy_array * 10)
     self.assertTrue(dm.has_lazy_data())
     dm.replace(self.real_array)
     self.assertFalse(dm.has_lazy_data())
     self.assertIs(dm._real_array, self.real_array)
     self.assertIs(dm.data, self.real_array)
Ejemplo n.º 15
0
 def test_lazy_with_lazy(self):
     lazy_array = as_lazy_data(self.real_array)
     dm = DataManager(lazy_array * 10)
     self.assertTrue(dm.has_lazy_data())
     dm.replace(lazy_array)
     self.assertTrue(dm.has_lazy_data())
     self.assertIs(dm._lazy_array, lazy_array)
     self.assertArrayEqual(dm.data, self.real_array)
Ejemplo n.º 16
0
 def test_lazy_with_lazy(self):
     lazy_array = as_lazy_data(self.real_array)
     dm = DataManager(lazy_array * 10)
     self.assertTrue(dm.has_lazy_data())
     dm.replace(lazy_array)
     self.assertTrue(dm.has_lazy_data())
     self.assertIs(dm._lazy_array, lazy_array)
     self.assertArrayEqual(dm.data, self.real_array)
Ejemplo n.º 17
0
 def test_with_lazy_mask_array__masked(self):
     dm = DataManager(self.lazy_mask_array_masked)
     self.assertTrue(dm.has_lazy_data())
     result = dm.data
     self.assertFalse(dm.has_lazy_data())
     self.assertIsInstance(result, ma.MaskedArray)
     self.assertEqual(dm.dtype, self.dtype)
     self.assertEqual(result.fill_value, self.fill_value)
     self.assertArrayEqual(result, self.mask_array_masked)
Ejemplo n.º 18
0
 def test_with_lazy_mask_array__masked(self):
     dm = DataManager(self.lazy_mask_array_masked)
     self.assertTrue(dm.has_lazy_data())
     result = dm.data
     self.assertFalse(dm.has_lazy_data())
     self.assertIsInstance(result, ma.MaskedArray)
     self.assertEqual(dm.dtype, self.dtype)
     self.assertEqual(result.fill_value, self.fill_value)
     self.assertArrayEqual(result, self.mask_array_masked)
Ejemplo n.º 19
0
 def test_nd_real_to_nd_real(self):
     shape = (2, 3, 4)
     size = np.prod(shape)
     real_array = np.arange(size).reshape(shape)
     dm = DataManager(real_array * 10)
     self.assertFalse(dm.has_lazy_data())
     dm.data = real_array
     self.assertFalse(dm.has_lazy_data())
     self.assertArrayEqual(dm.data, real_array)
Ejemplo n.º 20
0
 def test_nd_real_to_nd_real(self):
     shape = (2, 3, 4)
     size = np.prod(shape)
     real_array = np.arange(size).reshape(shape)
     dm = DataManager(real_array * 10)
     self.assertFalse(dm.has_lazy_data())
     dm.data = real_array
     self.assertFalse(dm.has_lazy_data())
     self.assertArrayEqual(dm.data, real_array)
Ejemplo n.º 21
0
 def test_with_lazy_mask_array__masked(self):
     dm = DataManager(self.lazy_mask_array_masked,
                      realised_dtype=self.realised_dtype)
     self.assertTrue(dm.has_lazy_data())
     result = dm.data
     self.assertFalse(dm.has_lazy_data())
     self.assertIsInstance(result, ma.MaskedArray)
     self.assertIsNone(dm._realised_dtype)
     self.assertEqual(dm.dtype, self.realised_dtype)
     self.assertArrayEqual(result, self.mask_array_masked)
Ejemplo n.º 22
0
 def test_nd_lazy_to_nd_lazy(self):
     shape = (2, 3, 4)
     size = np.prod(shape)
     real_array = np.arange(size).reshape(shape)
     lazy_array = as_lazy_data(real_array)
     dm = DataManager(lazy_array * 10)
     self.assertTrue(dm.has_lazy_data())
     dm.data = lazy_array
     self.assertTrue(dm.has_lazy_data())
     self.assertArrayEqual(dm.data, lazy_array.compute())
Ejemplo n.º 23
0
 def test_with_lazy_mask_array__masked(self):
     dm = DataManager(self.lazy_mask_array_masked,
                      realised_dtype=self.realised_dtype)
     self.assertTrue(dm.has_lazy_data())
     result = dm.data
     self.assertFalse(dm.has_lazy_data())
     self.assertIsInstance(result, ma.MaskedArray)
     self.assertIsNone(dm._realised_dtype)
     self.assertEqual(dm.dtype, self.realised_dtype)
     self.assertArrayEqual(result, self.lazy_mask_array_masked.compute())
Ejemplo n.º 24
0
 def test_nd_lazy_to_nd_lazy(self):
     shape = (2, 3, 4)
     size = np.prod(shape)
     real_array = np.arange(size).reshape(shape)
     lazy_array = as_lazy_data(real_array)
     dm = DataManager(lazy_array * 10)
     self.assertTrue(dm.has_lazy_data())
     dm.data = lazy_array
     self.assertTrue(dm.has_lazy_data())
     self.assertArrayEqual(dm.data, lazy_array.compute())
Ejemplo n.º 25
0
 def test_real_with_lazy__realised_dtype_setter_none(self):
     mask_array = ma.masked_array(self.real_array) * 10
     dtype = mask_array.dtype
     lazy_array = as_lazy_data(mask_array)
     dm = DataManager(self.real_array)
     self.assertFalse(dm.has_lazy_data())
     self.assertIsNone(dm._realised_dtype)
     self.assertEqual(dm.dtype, dtype)
     dm.replace(lazy_array, realised_dtype=dtype)
     self.assertTrue(dm.has_lazy_data())
     self.assertIsNone(dm._realised_dtype)
     self.assertEqual(dm.dtype, dtype)
     self.assertIs(dm._lazy_array, lazy_array)
     self.assertArrayEqual(dm.data, mask_array)
Ejemplo n.º 26
0
 def test_lazy_with_real__realised_dtype_none(self):
     mask_array = ma.arange(self.size).reshape(self.shape)
     dtype = mask_array.dtype
     lazy_array = as_lazy_data(mask_array)
     dm = DataManager(lazy_array, realised_dtype=dtype)
     self.assertTrue(dm.has_lazy_data())
     self.assertIsNone(dm._realised_dtype, dtype)
     self.assertEqual(dm.dtype, dtype)
     dm.replace(mask_array)
     self.assertFalse(dm.has_lazy_data())
     self.assertIsNone(dm._realised_dtype)
     self.assertEqual(dm.dtype, dtype)
     self.assertIs(dm._real_array, mask_array)
     self.assertIs(dm.data, mask_array)
Ejemplo n.º 27
0
 def test_real_with_lazy__realised_dtype_setter_none(self):
     mask_array = ma.masked_array(self.real_array) * 10
     dtype = mask_array.dtype
     lazy_array = as_lazy_data(mask_array)
     dm = DataManager(self.real_array)
     self.assertFalse(dm.has_lazy_data())
     self.assertIsNone(dm._realised_dtype)
     self.assertEqual(dm.dtype, dtype)
     dm.replace(lazy_array, realised_dtype=dtype)
     self.assertTrue(dm.has_lazy_data())
     self.assertIsNone(dm._realised_dtype)
     self.assertEqual(dm.dtype, dtype)
     self.assertIs(dm._lazy_array, lazy_array)
     self.assertArrayEqual(dm.data, mask_array)
Ejemplo n.º 28
0
 def test_lazy_with_real__realised_dtype_none(self):
     mask_array = ma.arange(self.size).reshape(self.shape)
     dtype = mask_array.dtype
     lazy_array = as_lazy_data(mask_array)
     dm = DataManager(lazy_array, realised_dtype=dtype)
     self.assertTrue(dm.has_lazy_data())
     self.assertIsNone(dm._realised_dtype, dtype)
     self.assertEqual(dm.dtype, dtype)
     dm.replace(mask_array)
     self.assertFalse(dm.has_lazy_data())
     self.assertIsNone(dm._realised_dtype)
     self.assertEqual(dm.dtype, dtype)
     self.assertIs(dm._real_array, mask_array)
     self.assertIs(dm.data, mask_array)
Ejemplo n.º 29
0
 def test_with_real_masked_constant(self):
     masked_data = ma.masked_array([666], mask=True, dtype=np.dtype('f8'))
     masked_constant = masked_data[0]
     dm = DataManager(masked_constant)
     result = dm.data
     self.assertFalse(dm.has_lazy_data())
     self.assertIsInstance(result, ma.MaskedArray)
     self.assertNotIsInstance(result, ma.core.MaskedConstant)
     self.assertMaskedArrayEqual(result, masked_data)
Ejemplo n.º 30
0
 def test_with_real_masked_constant(self):
     masked_data = ma.masked_array([666], mask=True, dtype=np.dtype('f8'))
     masked_constant = masked_data[0]
     dm = DataManager(masked_constant)
     result = dm.data
     self.assertFalse(dm.has_lazy_data())
     self.assertIsInstance(result, ma.MaskedArray)
     self.assertNotIsInstance(result, ma.core.MaskedConstant)
     self.assertMaskedArrayEqual(result, masked_data)
Ejemplo n.º 31
0
 def test_with_lazy_masked_constant(self):
     dtype = np.dtype('int16')
     masked_data = ma.masked_array([666], mask=True, dtype=dtype)
     masked_constant = masked_data[0]
     lazy_masked_constant = as_lazy_data(masked_constant)
     dm = DataManager(lazy_masked_constant, realised_dtype=dtype)
     self.assertEqual(dm.dtype, dtype)
     result = dm.data
     self.assertFalse(dm.has_lazy_data())
     self.assertIsInstance(result, ma.MaskedArray)
     self.assertNotIsInstance(result, ma.core.MaskedConstant)
     self.assertMaskedArrayEqual(result, masked_data)
Ejemplo n.º 32
0
 def test_with_lazy_masked_constant(self):
     dtype = np.dtype('int16')
     masked_data = ma.masked_array([666], mask=True, dtype=dtype)
     masked_constant = masked_data[0]
     lazy_masked_constant = as_lazy_data(masked_constant)
     dm = DataManager(lazy_masked_constant, realised_dtype=dtype)
     self.assertEqual(dm.dtype, dtype)
     result = dm.data
     self.assertFalse(dm.has_lazy_data())
     self.assertIsInstance(result, ma.MaskedArray)
     self.assertNotIsInstance(result, ma.core.MaskedConstant)
     self.assertMaskedArrayEqual(result, masked_data)
Ejemplo n.º 33
0
 def test_with_lazy_array(self):
     dm = DataManager(self.lazy_array)
     self.assertTrue(dm.has_lazy_data())
     result = dm.lazy_data()
     self.assertTrue(dm.has_lazy_data())
     self.assertIs(result, dm._lazy_array)
Ejemplo n.º 34
0
 def test_with_lazy_array(self):
     dm = DataManager(self.lazy_array)
     self.assertTrue(dm.has_lazy_data())
     result = dm.lazy_data()
     self.assertTrue(dm.has_lazy_data())
     self.assertIs(result, dm._lazy_array)
Ejemplo n.º 35
0
 def test_with_lazy_array(self):
     dm = DataManager(self.lazy_array)
     self.assertTrue(dm.has_lazy_data())
Ejemplo n.º 36
0
 def test_with_real_array(self):
     dm = DataManager(self.real_array)
     self.assertFalse(dm.has_lazy_data())
Ejemplo n.º 37
0
 def test_with_real_array(self):
     dm = DataManager(self.real_array)
     self.assertFalse(dm.has_lazy_data())
Ejemplo n.º 38
0
 def test_with_lazy_array(self):
     dm = DataManager(self.lazy_array)
     self.assertTrue(dm.has_lazy_data())