Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
 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.",
     )
Ejemplo n.º 8
0
 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.')
Ejemplo n.º 9
0
 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.')
Ejemplo n.º 10
0
 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.')
Ejemplo n.º 11
0
 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.')
Ejemplo n.º 12
0
 def test_no_bounds(self):
     coord = AuxCoord(self.pts_real)
     result = coord.core_bounds()
     self.assertIsNone(result)
Ejemplo n.º 13
0
 def test_lazy_bounds(self):
     coord = AuxCoord(self.pts_real, bounds=self.bds_lazy)
     result = coord.core_bounds()
     self.assertEqualLazyArraysAndDtypes(result, self.bds_lazy)
Ejemplo n.º 14
0
 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)
Ejemplo n.º 15
0
 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)
Ejemplo n.º 16
0
 def test_lazy_bounds(self):
     coord = AuxCoord(self.pts_real, bounds=self.bds_lazy)
     result = coord.core_bounds()
     self.assertEqualLazyArraysAndDtypes(result, self.bds_lazy)
Ejemplo n.º 17
0
 def test_no_bounds(self):
     coord = AuxCoord(self.pts_real)
     result = coord.core_bounds()
     self.assertIsNone(result)
Ejemplo n.º 18
0
 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.')
Ejemplo n.º 19
0
 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)
Ejemplo n.º 20
0
 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)
Ejemplo n.º 21
0
 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)