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)
Exemple #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)
 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)
Exemple #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)
Exemple #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)
 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)
Exemple #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)
 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)
 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)
Exemple #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)
Exemple #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)
Exemple #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)
 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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
 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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
 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)