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_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_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)
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)
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)