Пример #1
0
 def test_numpy_scalar_coord__zero_ndim(self):
     points = np.array(0.5)
     bounds = np.arange(2)
     coord = AuxCoord(points, bounds=bounds)
     result = AuxCoordFactory._nd_bounds(coord, (), 0)
     expected = bounds
     self.assertArrayEqual(result, expected)
Пример #2
0
 def test_numpy_scalar_coord__zero_ndim(self):
     points = np.array(0.5)
     bounds = np.arange(2)
     coord = AuxCoord(points, bounds=bounds)
     result = AuxCoordFactory._nd_bounds(coord, (), 0)
     expected = bounds
     self.assertArrayEqual(result, expected)
Пример #3
0
 def test_numpy_scalar_coord(self):
     points = np.array(0.5)
     bounds = np.arange(2).reshape(1, 2)
     coord = AuxCoord(points, bounds=bounds)
     result = AuxCoordFactory._nd_bounds(coord, (), 2)
     expected = bounds[np.newaxis]
     self.assertArrayEqual(result, expected)
Пример #4
0
 def test_numpy_simple(self):
     points = np.arange(12).reshape(4, 3)
     bounds = np.arange(24).reshape(4, 3, 2)
     coord = AuxCoord(points, bounds=bounds)
     result = AuxCoordFactory._nd_bounds(coord, (0, 1), 2)
     expected = bounds
     self.assertArrayEqual(result, expected)
Пример #5
0
 def test_numpy_scalar_coord(self):
     value = 1
     points = np.array(value)
     coord = AuxCoord(points)
     result = AuxCoordFactory._nd_points(coord, (), 2)
     expected = np.array(value).reshape(1, 1)
     self.assertArrayEqual(result, expected)
Пример #6
0
 def test_numpy_scalar_coord(self):
     value = 1
     points = np.array(value)
     coord = AuxCoord(points)
     result = AuxCoordFactory._nd_points(coord, (), 2)
     expected = np.array(value).reshape(1, 1)
     self.assertArrayEqual(result, expected)
Пример #7
0
 def test_numpy_complex(self):
     points = np.arange(12).reshape(4, 3)
     bounds = np.arange(24).reshape(4, 3, 2)
     coord = AuxCoord(points, bounds=bounds)
     result = AuxCoordFactory._nd_bounds(coord, (3, 2), 5)
     expected = bounds.transpose((1, 0, 2)).reshape(1, 1, 3, 4, 1, 2)
     self.assertArrayEqual(result, expected)
Пример #8
0
 def test_numpy_complex(self):
     points = np.arange(12).reshape(4, 3)
     bounds = np.arange(24).reshape(4, 3, 2)
     coord = AuxCoord(points, bounds=bounds)
     result = AuxCoordFactory._nd_bounds(coord, (3, 2), 5)
     expected = bounds.transpose((1, 0, 2)).reshape(1, 1, 3, 4, 1, 2)
     self.assertArrayEqual(result, expected)
Пример #9
0
 def test_numpy_simple(self):
     points = np.arange(12).reshape(4, 3)
     bounds = np.arange(24).reshape(4, 3, 2)
     coord = AuxCoord(points, bounds=bounds)
     result = AuxCoordFactory._nd_bounds(coord, (0, 1), 2)
     expected = bounds
     self.assertArrayEqual(result, expected)
Пример #10
0
 def test_numpy_scalar_coord(self):
     points = np.array(0.5)
     bounds = np.arange(2).reshape(1, 2)
     coord = AuxCoord(points, bounds=bounds)
     result = AuxCoordFactory._nd_bounds(coord, (), 2)
     expected = bounds[np.newaxis]
     self.assertArrayEqual(result, expected)
Пример #11
0
 def test_lazy_complex(self):
     raw_points = np.arange(12).reshape(4, 3)
     points = as_lazy_data(raw_points, raw_points.shape)
     coord = AuxCoord(points)
     self.assertTrue(is_lazy_data(coord.core_points()))
     result = AuxCoordFactory._nd_points(coord, (3, 2), 5)
     # Check we haven't triggered the loading of the coordinate values.
     self.assertTrue(is_lazy_data(coord.core_points()))
     self.assertTrue(is_lazy_data(result))
     expected = raw_points.T[np.newaxis, np.newaxis, ..., np.newaxis]
     self.assertArrayEqual(result, expected)
Пример #12
0
 def test_lazy_complex(self):
     raw_points = np.arange(12).reshape(4, 3)
     points = as_lazy_data(raw_points, raw_points.shape)
     coord = AuxCoord(points)
     self.assertTrue(is_lazy_data(coord.core_points()))
     result = AuxCoordFactory._nd_points(coord, (3, 2), 5)
     # Check we haven't triggered the loading of the coordinate values.
     self.assertTrue(is_lazy_data(coord.core_points()))
     self.assertTrue(is_lazy_data(result))
     expected = raw_points.T[np.newaxis, np.newaxis, ..., np.newaxis]
     self.assertArrayEqual(result, expected)
Пример #13
0
 def test_biggus_complex(self):
     raw_points = np.arange(12).reshape(4, 3)
     points = biggus.NumpyArrayAdapter(raw_points)
     coord = iris.coords.AuxCoord(points)
     self.assertIsInstance(coord._points, biggus.Array)
     result = AuxCoordFactory._nd_points(coord, (3, 2), 5)
     # Check we haven't triggered the loading of the coordinate values.
     self.assertIsInstance(coord._points, biggus.Array)
     self.assertIsInstance(result, biggus.Array)
     expected = raw_points.T[np.newaxis, np.newaxis, ..., np.newaxis]
     self.assertArrayEqual(result, expected)
Пример #14
0
 def test_biggus_complex(self):
     raw_points = np.arange(12).reshape(4, 3)
     points = biggus.NumpyArrayAdapter(raw_points)
     coord = iris.coords.AuxCoord(points)
     self.assertIsInstance(coord._points, biggus.Array)
     result = AuxCoordFactory._nd_points(coord, (3, 2), 5)
     # Check we haven't triggered the loading of the coordinate values.
     self.assertIsInstance(coord._points, biggus.Array)
     self.assertIsInstance(result, biggus.Array)
     expected = raw_points.T[np.newaxis, np.newaxis, ..., np.newaxis]
     self.assertArrayEqual(result, expected)
Пример #15
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)
Пример #16
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)
Пример #17
0
 def test_numpy_scalar_coord__zero_ndim(self):
     points = np.array(1)
     coord = AuxCoord(points)
     result = AuxCoordFactory._nd_points(coord, (), 0)
     expected = np.array([1])
     self.assertArrayEqual(result, expected)
Пример #18
0
 def test_numpy_scalar_coord__zero_ndim(self):
     points = np.array(1)
     coord = AuxCoord(points)
     result = AuxCoordFactory._nd_points(coord, (), 0)
     expected = np.array([1])
     self.assertArrayEqual(result, expected)
Пример #19
0
 def test_numpy_simple(self):
     points = np.arange(12).reshape(4, 3)
     coord = iris.coords.AuxCoord(points)
     result = AuxCoordFactory._nd_points(coord, (0, 1), 2)
     expected = points
     self.assertArrayEqual(result, expected)
Пример #20
0
 def test_numpy_complex(self):
     points = np.arange(12).reshape(4, 3)
     coord = iris.coords.AuxCoord(points)
     result = AuxCoordFactory._nd_points(coord, (3, 2), 5)
     expected = points.T[np.newaxis, np.newaxis, ..., np.newaxis]
     self.assertArrayEqual(result, expected)
Пример #21
0
 def test_numpy_complex(self):
     points = np.arange(12).reshape(4, 3)
     coord = AuxCoord(points)
     result = AuxCoordFactory._nd_points(coord, (3, 2), 5)
     expected = points.T[np.newaxis, np.newaxis, ..., np.newaxis]
     self.assertArrayEqual(result, expected)
Пример #22
0
 def test_numpy_scalar_cooord(self):
     points = np.arange(1)
     coord = iris.coords.AuxCoord(points)
     result = AuxCoordFactory._nd_points(coord, (), 2)
     expected = points[np.newaxis]
     self.assertArrayEqual(result, expected)
Пример #23
0
 def test_numpy_simple(self):
     points = np.arange(12).reshape(4, 3)
     coord = iris.coords.AuxCoord(points)
     result = AuxCoordFactory._nd_points(coord, (0, 1), 2)
     expected = points
     self.assertArrayEqual(result, expected)
Пример #24
0
 def test_numpy_scalar_cooord(self):
     points = np.arange(1)
     coord = iris.coords.AuxCoord(points)
     result = AuxCoordFactory._nd_points(coord, (), 2)
     expected = points[np.newaxis]
     self.assertArrayEqual(result, expected)