Example #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)
Example #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)
Example #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)
Example #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)
Example #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)
Example #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)
Example #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.",
     )
Example #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.')
Example #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.')
Example #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.')
Example #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.')
Example #12
0
 def test_no_bounds(self):
     coord = AuxCoord(self.pts_real)
     result = coord.core_bounds()
     self.assertIsNone(result)
Example #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)
Example #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)
Example #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)
Example #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)
Example #17
0
 def test_no_bounds(self):
     coord = AuxCoord(self.pts_real)
     result = coord.core_bounds()
     self.assertIsNone(result)
Example #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.')
Example #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)
Example #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)
Example #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)