예제 #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)