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