Skip to content

Commit

Permalink
Everything in 'TestConcatenate__dask' can use the same sample cubes.
Browse files Browse the repository at this point in the history
  • Loading branch information
pp-mo committed Mar 11, 2024
1 parent 3f1eae2 commit 2427de8
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions lib/iris/tests/unit/concatenate/test_concatenate.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,23 +324,22 @@ def test_desc_bounds_all_singleton(self):


class TestConcatenate__dask:
@staticmethod
def build_lazy_cube(points):
nx = 4
data = np.arange(len(points) * nx).reshape(len(points), nx)
data = as_lazy_data(data)
cube = iris.cube.Cube(data, standard_name="air_temperature", units="K")
lat = iris.coords.DimCoord(points, "latitude")
lon = iris.coords.DimCoord(np.arange(nx), "longitude")
cube.add_dim_coord(lat, 0)
cube.add_dim_coord(lon, 1)
return cube

@pytest.fixture()
def sample_lazy_cubes(self):
# Make a pair of concatenatable cubes, with dim points [1, 2] and [3, 4, 5]
c1 = self.build_lazy_cube([1, 2])
c2 = self.build_lazy_cube([3, 4, 5])
def build_lazy_cube(points):
nx = 4
data = np.arange(len(points) * nx).reshape(len(points), nx)
data = as_lazy_data(data)
cube = iris.cube.Cube(data, standard_name="air_temperature", units="K")
lat = iris.coords.DimCoord(points, "latitude")
lon = iris.coords.DimCoord(np.arange(nx), "longitude")
cube.add_dim_coord(lat, 0)
cube.add_dim_coord(lon, 1)
return cube

c1 = build_lazy_cube([1, 2])
c2 = build_lazy_cube([3, 4, 5])
return c1, c2

@staticmethod
Expand All @@ -363,7 +362,6 @@ def test_lazy_concatenate(self, sample_lazy_cubes):

def test_lazy_concatenate_aux_coords(self, sample_lazy_cubes):
c1, c2 = sample_lazy_cubes
c2 = self.build_lazy_cube([3, 4, 5])
for cube in (c1, c2):
self.add_sample_auxcoord(cube)
(result,) = concatenate([c1, c2])
Expand Down

0 comments on commit 2427de8

Please sign in to comment.