def test_lazy_complex(self): raw_points = np.arange(12).reshape(4, 3) points = as_lazy_data(raw_points, raw_points.shape) raw_bounds = np.arange(24).reshape(4, 3, 2) bounds = as_lazy_data(raw_bounds, raw_bounds.shape) coord = AuxCoord(points, bounds=bounds) self.assertTrue(is_lazy_data(coord.core_bounds())) result = AuxCoordFactory._nd_bounds(coord, (3, 2), 5) # Check we haven't triggered the loading of the coordinate values. self.assertTrue(is_lazy_data(coord.core_bounds())) self.assertTrue(is_lazy_data(result)) expected = raw_bounds.transpose((1, 0, 2)).reshape(1, 1, 3, 4, 1, 2) self.assertArrayEqual(result, expected)
def test_lazy_complex(self): raw_points = np.arange(12).reshape(4, 3) points = as_lazy_data(raw_points, raw_points.shape) raw_bounds = np.arange(24).reshape(4, 3, 2) bounds = as_lazy_data(raw_bounds, raw_bounds.shape) coord = AuxCoord(points, bounds=bounds) self.assertTrue(is_lazy_data(coord.core_bounds())) result = AuxCoordFactory._nd_bounds(coord, (3, 2), 5) # Check we haven't triggered the loading of the coordinate values. self.assertTrue(is_lazy_data(coord.core_bounds())) self.assertTrue(is_lazy_data(result)) expected = raw_bounds.transpose((1, 0, 2)).reshape(1, 1, 3, 4, 1, 2) self.assertArrayEqual(result, expected)
def test_set_points_with_lazy_bounds(self): # Setting points does not touch lazy bounds. coord = AuxCoord(self.pts_real, bounds=self.bds_lazy) new_pts = self.pts_real + 102.3 coord.points = new_pts result = coord.core_bounds() self.assertEqualLazyArraysAndDtypes(result, self.bds_lazy)
def test_set_lazy_bounds(self): # Setting new lazy bounds. coord = AuxCoord(self.pts_real, bounds=self.bds_real) new_bounds = self.bds_lazy + 102.3 coord.bounds = new_bounds result = coord.core_bounds() self.assertEqualLazyArraysAndDtypes(result, new_bounds)
def test_set_points_with_lazy_bounds(self): # Setting points does not touch lazy bounds. coord = AuxCoord(self.pts_real, bounds=self.bds_lazy) new_pts = self.pts_real + 102.3 coord.points = new_pts result = coord.core_bounds() self.assertEqualLazyArraysAndDtypes(result, self.bds_lazy)
def test_set_lazy_bounds(self): # Setting new lazy bounds. coord = AuxCoord(self.pts_real, bounds=self.bds_real) new_bounds = self.bds_lazy + 102.3 coord.bounds = new_bounds result = coord.core_bounds() self.assertEqualLazyArraysAndDtypes(result, new_bounds)
def test_real_bounds(self): coord = AuxCoord(self.pts_real, bounds=self.bds_real) result = coord.core_bounds() self.assertArraysShareData( result, self.bds_real, "core_bounds() do not share data with the internal array.", )
def test_real_points_with_real_bounds(self): # Getting real points does not change real bounds. coord = AuxCoord(self.pts_real, bounds=self.bds_real) coord.points result = coord.core_bounds() self.assertArraysShareData( result, self.bds_real, 'Bounds do not share data with the provided array.')
def test_real_points_with_real_bounds(self): # Getting real points does not change real bounds. coord = AuxCoord(self.pts_real, bounds=self.bds_real) coord.points result = coord.core_bounds() self.assertArraysShareData( result, self.bds_real, 'Bounds do not share data with the provided array.')
def test_set_real_bounds(self): # Setting new real bounds does not make a copy. coord = AuxCoord(self.pts_real, bounds=self.bds_real) new_bounds = self.bds_real + 102.3 coord.bounds = new_bounds result = coord.core_bounds() self.assertArraysShareData( result, new_bounds, 'Bounds do not share data with the assigned array.')
def test_set_real_bounds(self): # Setting new real bounds does not make a copy. coord = AuxCoord(self.pts_real, bounds=self.bds_real) new_bounds = self.bds_real + 102.3 coord.bounds = new_bounds result = coord.core_bounds() self.assertArraysShareData( result, new_bounds, 'Bounds do not share data with the assigned array.')
def test_no_bounds(self): coord = AuxCoord(self.pts_real) result = coord.core_bounds() self.assertIsNone(result)
def test_lazy_bounds(self): coord = AuxCoord(self.pts_real, bounds=self.bds_lazy) result = coord.core_bounds() self.assertEqualLazyArraysAndDtypes(result, self.bds_lazy)
def test_lazy_points_with_real_bounds(self): # Getting lazy points does not affect real bounds. coord = AuxCoord(self.pts_lazy, bounds=self.bds_real) coord.points result = coord.core_bounds() self.assertEqualRealArraysAndDtypes(result, self.bds_real)
def test_lazy_bounds_realise(self): coord = AuxCoord(self.pts_real, bounds=self.bds_lazy) real_bounds = coord.bounds result = coord.core_bounds() self.assertEqualRealArraysAndDtypes(result, real_bounds)
def test_lazy_bounds(self): coord = AuxCoord(self.pts_real, bounds=self.bds_lazy) result = coord.core_bounds() self.assertEqualLazyArraysAndDtypes(result, self.bds_lazy)
def test_no_bounds(self): coord = AuxCoord(self.pts_real) result = coord.core_bounds() self.assertIsNone(result)
def test_real_bounds(self): coord = AuxCoord(self.pts_real, bounds=self.bds_real) result = coord.core_bounds() self.assertArraysShareData( result, self.bds_real, 'core_bounds() do not share data with the internal array.')
def test_lazy_bounds_realise(self): coord = AuxCoord(self.pts_real, bounds=self.bds_lazy) real_bounds = coord.bounds result = coord.core_bounds() self.assertIs(result, real_bounds)
def test_lazy_points_with_real_bounds(self): # Getting lazy points does not affect real bounds. coord = AuxCoord(self.pts_lazy, bounds=self.bds_real) coord.points result = coord.core_bounds() self.assertEqualRealArraysAndDtypes(result, self.bds_real)
def test_lazy_bounds_realise(self): coord = AuxCoord(self.pts_real, bounds=self.bds_lazy) real_bounds = coord.bounds result = coord.core_bounds() self.assertEqualRealArraysAndDtypes(result, real_bounds)