From 2e7bddc72c60558f347b7972e9c35a7e94e62fca Mon Sep 17 00:00:00 2001 From: Patrick Peglar Date: Mon, 11 Mar 2024 15:46:04 +0000 Subject: [PATCH 1/4] Convert all tests to pytest. --- .../unit/concatenate/test_concatenate.py | 324 ++++++++---------- 1 file changed, 152 insertions(+), 172 deletions(-) diff --git a/lib/iris/tests/unit/concatenate/test_concatenate.py b/lib/iris/tests/unit/concatenate/test_concatenate.py index 34db2b02f1..79953fa9bf 100644 --- a/lib/iris/tests/unit/concatenate/test_concatenate.py +++ b/lib/iris/tests/unit/concatenate/test_concatenate.py @@ -3,14 +3,10 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Test function :func:`iris._concatenate.concatenate.py`.""" - -# import iris tests first so that some things can be initialised -# before importing anything else. -import iris.tests as tests # isort:skip - import cf_units import numpy as np import numpy.ma as ma +import pytest from iris._concatenate import concatenate from iris._lazy_data import as_lazy_data @@ -20,10 +16,17 @@ from iris.exceptions import ConcatenateError -class TestEpoch(tests.IrisTest): - def simple_1d_time_cubes(self, reftimes, coords_points): - cubes = [] +class TestEpoch: + @pytest.fixture() + @staticmethod + def simple_1d_time_cubes(): + reftimes = [ + "hours since 1970-01-01 00:00:00", + "hours since 1970-01-01 00:00:00", + ] + coords_points = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]] data_points = [273, 275, 278, 277, 274] + cubes = [] for reftime, coord_points in zip(reftimes, coords_points): cube = iris.cube.Cube( np.array(data_points, dtype=np.float32), @@ -40,20 +43,17 @@ def simple_1d_time_cubes(self, reftimes, coords_points): cubes.append(cube) return cubes - def test_concat_1d_with_same_time_units(self): - reftimes = [ - "hours since 1970-01-01 00:00:00", - "hours since 1970-01-01 00:00:00", - ] - coords_points = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]] - cubes = self.simple_1d_time_cubes(reftimes, coords_points) - result = concatenate(cubes) - self.assertEqual(len(result), 1) - self.assertEqual(result[0].shape, (10,)) + def test_concat_1d_with_same_time_units(self, simple_1d_time_cubes): + result = concatenate(simple_1d_time_cubes) + assert len(result) == 1 + assert result[0].shape == (10,) -class TestMessages(tests.IrisTest): - def setUp(self): +class TestMessages: + @pytest.fixture() + @staticmethod + def sample_cubes(): + # Construct and return a pair of identical cubes data = np.arange(24, dtype=np.float32).reshape(2, 3, 4) cube = iris.cube.Cube(data, standard_name="air_temperature", units="K") # Time coord @@ -106,115 +106,90 @@ def setUp(self): cube.add_aux_coord(sigma, ()) cube.add_aux_coord(orog, ()) cube.add_aux_factory(HybridHeightFactory(delta, sigma, orog)) - self.cube = cube - - def test_definition_difference_message(self): - cube_1 = self.cube - cube_2 = cube_1.copy() - cube_2.units = "1" - exc_regexp = "Cube metadata differs for phenomenon: *" - with self.assertRaisesRegex(ConcatenateError, exc_regexp): - _ = concatenate([cube_1, cube_2], True) - - def test_dimensions_difference_message(self): - cube_1 = self.cube - cube_2 = cube_1.copy() - cube_2.remove_coord("latitude") + # Return a list with two identical cubes + return [cube, cube.copy()] + + def test_definition_difference_message(self, sample_cubes): + sample_cubes[1].units = "1" + exc_regexp = "Cube metadata differs for phenomenon:" + with pytest.raises(ConcatenateError, match=exc_regexp): + _ = concatenate(sample_cubes, True) + + def test_dimensions_difference_message(self, sample_cubes): + sample_cubes[1].remove_coord("latitude") exc_regexp = "Dimension coordinates differ: .* != .*" - with self.assertRaisesRegex(ConcatenateError, exc_regexp): - _ = concatenate([cube_1, cube_2], True) + with pytest.raises(ConcatenateError, match=exc_regexp): + _ = concatenate(sample_cubes, True) - def test_dimensions_metadata_difference_message(self): - cube_1 = self.cube - cube_2 = cube_1.copy() - cube_2.coord("latitude").long_name = "bob" + def test_dimensions_metadata_difference_message(self, sample_cubes): + sample_cubes[1].coord("latitude").long_name = "bob" exc_regexp = "Dimension coordinates metadata differ: .* != .*" - with self.assertRaisesRegex(ConcatenateError, exc_regexp): - _ = concatenate([cube_1, cube_2], True) + with pytest.raises(ConcatenateError, match=exc_regexp): + _ = concatenate(sample_cubes, True) - def test_aux_coords_difference_message(self): - cube_1 = self.cube - cube_2 = cube_1.copy() - cube_2.remove_coord("foo") + def test_aux_coords_difference_message(self, sample_cubes): + sample_cubes[1].remove_coord("foo") exc_regexp = "Auxiliary coordinates differ: .* != .*" - with self.assertRaisesRegex(ConcatenateError, exc_regexp): - _ = concatenate([cube_1, cube_2], True) + with pytest.raises(ConcatenateError, match=exc_regexp): + _ = concatenate(sample_cubes, True) - def test_aux_coords_metadata_difference_message(self): - cube_1 = self.cube - cube_2 = cube_1.copy() - cube_2.coord("foo").units = "m" + def test_aux_coords_metadata_difference_message(self, sample_cubes): + sample_cubes[1].coord("foo").units = "m" exc_regexp = "Auxiliary coordinates metadata differ: .* != .*" - with self.assertRaisesRegex(ConcatenateError, exc_regexp): - _ = concatenate([cube_1, cube_2], True) + with pytest.raises(ConcatenateError, match=exc_regexp): + _ = concatenate(sample_cubes, True) - def test_scalar_coords_difference_message(self): - cube_1 = self.cube - cube_2 = cube_1.copy() - cube_2.remove_coord("height") + def test_scalar_coords_difference_message(self, sample_cubes): + sample_cubes[1].remove_coord("height") exc_regexp = "Scalar coordinates differ: .* != .*" - with self.assertRaisesRegex(ConcatenateError, exc_regexp): - _ = concatenate([cube_1, cube_2], True) + with pytest.raises(ConcatenateError, match=exc_regexp): + _ = concatenate(sample_cubes, True) - def test_scalar_coords_metadata_difference_message(self): - cube_1 = self.cube - cube_2 = cube_1.copy() - cube_2.coord("height").long_name = "alice" + def test_scalar_coords_metadata_difference_message(self, sample_cubes): + sample_cubes[1].coord("height").long_name = "alice" exc_regexp = "Scalar coordinates values or metadata differ: .* != .*" - with self.assertRaisesRegex(ConcatenateError, exc_regexp): - _ = concatenate([cube_1, cube_2], True) + with pytest.raises(ConcatenateError, match=exc_regexp): + _ = concatenate(sample_cubes, True) - def test_cell_measure_difference_message(self): - cube_1 = self.cube - cube_2 = cube_1.copy() - cube_2.remove_cell_measure("bar") + def test_cell_measure_difference_message(self, sample_cubes): + sample_cubes[1].remove_cell_measure("bar") exc_regexp = "Cell measures differ: .* != .*" - with self.assertRaisesRegex(ConcatenateError, exc_regexp): - _ = concatenate([cube_1, cube_2], True) + with pytest.raises(ConcatenateError, match=exc_regexp): + _ = concatenate(sample_cubes, True) - def test_cell_measure_metadata_difference_message(self): - cube_1 = self.cube - cube_2 = cube_1.copy() - cube_2.cell_measure("bar").units = "m" + def test_cell_measure_metadata_difference_message(self, sample_cubes): + sample_cubes[1].cell_measure("bar").units = "m" exc_regexp = "Cell measures metadata differ: .* != .*" - with self.assertRaisesRegex(ConcatenateError, exc_regexp): - _ = concatenate([cube_1, cube_2], True) + with pytest.raises(ConcatenateError, match=exc_regexp): + _ = concatenate(sample_cubes, True) - def test_ancillary_variable_difference_message(self): - cube_1 = self.cube - cube_2 = cube_1.copy() - cube_2.remove_ancillary_variable("baz") + def test_ancillary_variable_difference_message(self, sample_cubes): + sample_cubes[1].remove_ancillary_variable("baz") exc_regexp = "Ancillary variables differ: .* != .*" - with self.assertRaisesRegex(ConcatenateError, exc_regexp): - _ = concatenate([cube_1, cube_2], True) + with pytest.raises(ConcatenateError, match=exc_regexp): + _ = concatenate(sample_cubes, True) - def test_ancillary_variable_metadata_difference_message(self): - cube_1 = self.cube - cube_2 = cube_1.copy() - cube_2.ancillary_variable("baz").units = "m" + def test_ancillary_variable_metadata_difference_message(self, sample_cubes): + sample_cubes[1].ancillary_variable("baz").units = "m" exc_regexp = "Ancillary variables metadata differ: .* != .*" - with self.assertRaisesRegex(ConcatenateError, exc_regexp): - _ = concatenate([cube_1, cube_2], True) + with pytest.raises(ConcatenateError, match=exc_regexp): + _ = concatenate(sample_cubes, True) - def test_derived_coord_difference_message(self): - cube_1 = self.cube - cube_2 = cube_1.copy() - cube_2.remove_aux_factory(cube_2.aux_factories[0]) + def test_derived_coord_difference_message(self, sample_cubes): + sample_cubes[1].remove_aux_factory(sample_cubes[1].aux_factories[0]) exc_regexp = "Derived coordinates differ: .* != .*" - with self.assertRaisesRegex(ConcatenateError, exc_regexp): - _ = concatenate([cube_1, cube_2], True) + with pytest.raises(ConcatenateError, match=exc_regexp): + _ = concatenate(sample_cubes, True) - def test_derived_coord_metadata_difference_message(self): - cube_1 = self.cube - cube_2 = cube_1.copy() - cube_2.aux_factories[0].units = "km" + def test_derived_coord_metadata_difference_message(self, sample_cubes): + sample_cubes[1].aux_factories[0].units = "km" exc_regexp = "Derived coordinates metadata differ: .* != .*" - with self.assertRaisesRegex(ConcatenateError, exc_regexp): - _ = concatenate([cube_1, cube_2], True) + with pytest.raises(ConcatenateError, match=exc_regexp): + _ = concatenate(sample_cubes, True) - def test_ndim_difference_message(self): - cube_1 = self.cube - cube_2 = iris.cube.Cube( + def test_ndim_difference_message(self, sample_cubes): + # Replace cube#2 with an entirely different thing + sample_cubes[1] = iris.cube.Cube( np.arange(5, dtype=np.float32), standard_name="air_temperature", units="K", @@ -224,29 +199,25 @@ def test_ndim_difference_message(self): standard_name="longitude", units="degrees", ) - cube_2.add_dim_coord(x_coord, 0) + sample_cubes[1].add_dim_coord(x_coord, 0) exc_regexp = "Data dimensions differ: [0-9] != [0-9]" - with self.assertRaisesRegex(ConcatenateError, exc_regexp): - _ = concatenate([cube_1, cube_2], True) + with pytest.raises(ConcatenateError, match=exc_regexp): + _ = concatenate(sample_cubes, True) - def test_datatype_difference_message(self): - cube_1 = self.cube - cube_2 = cube_1.copy() - cube_2.data.dtype = np.float64 + def test_datatype_difference_message(self, sample_cubes): + sample_cubes[1].data.dtype = np.float64 exc_regexp = "Data types differ: .* != .*" - with self.assertRaisesRegex(ConcatenateError, exc_regexp): - _ = concatenate([cube_1, cube_2], True) + with pytest.raises(ConcatenateError, match=exc_regexp): + _ = concatenate(sample_cubes, True) - def test_dim_coords_overlap_message(self): - cube_1 = self.cube - cube_2 = cube_1.copy() - cube_2.coord("time").points = np.arange(1, 3, dtype=np.float32) + def test_dim_coords_overlap_message(self, sample_cubes): + sample_cubes[1].coord("time").points = np.arange(1, 3, dtype=np.float32) exc_regexp = "Found cubes with overlap on concatenate axis" - with self.assertRaisesRegex(ConcatenateError, exc_regexp): - _ = concatenate([cube_1, cube_2], True) + with pytest.raises(ConcatenateError, match=exc_regexp): + _ = concatenate(sample_cubes, True) -class TestOrder(tests.IrisTest): +class TestOrder: def _make_cube(self, points, bounds=None): nx = 4 data = np.arange(len(points) * nx).reshape(len(points), nx) @@ -261,147 +232,156 @@ def test_asc_points(self): top = self._make_cube([10, 30, 50, 70, 90]) bottom = self._make_cube([-90, -70, -50, -30, -10]) result = concatenate([top, bottom]) - self.assertEqual(len(result), 1) + assert len(result) == 1 def test_asc_bounds(self): top = self._make_cube([22.5, 67.5], [[0, 45], [45, 90]]) bottom = self._make_cube([-67.5, -22.5], [[-90, -45], [-45, 0]]) result = concatenate([top, bottom]) - self.assertEqual(len(result), 1) + assert len(result) == 1 def test_asc_points_with_singleton_ordered(self): top = self._make_cube([5]) bottom = self._make_cube([15, 25]) result = concatenate([top, bottom]) - self.assertEqual(len(result), 1) + assert len(result) == 1 def test_asc_points_with_singleton_unordered(self): top = self._make_cube([25]) bottom = self._make_cube([5, 15]) result = concatenate([top, bottom]) - self.assertEqual(len(result), 1) + assert len(result) == 1 def test_asc_bounds_with_singleton_ordered(self): top = self._make_cube([5], [[0, 10]]) bottom = self._make_cube([15, 25], [[10, 20], [20, 30]]) result = concatenate([top, bottom]) - self.assertEqual(len(result), 1) + assert len(result) == 1 def test_asc_bounds_with_singleton_unordered(self): top = self._make_cube([25], [[20, 30]]) bottom = self._make_cube([5, 15], [[0, 10], [10, 20]]) result = concatenate([top, bottom]) - self.assertEqual(len(result), 1) + assert len(result) == 1 def test_desc_points(self): top = self._make_cube([90, 70, 50, 30, 10]) bottom = self._make_cube([-10, -30, -50, -70, -90]) result = concatenate([top, bottom]) - self.assertEqual(len(result), 1) + assert len(result) == 1 def test_desc_bounds(self): top = self._make_cube([67.5, 22.5], [[90, 45], [45, 0]]) bottom = self._make_cube([-22.5, -67.5], [[0, -45], [-45, -90]]) result = concatenate([top, bottom]) - self.assertEqual(len(result), 1) + assert len(result) == 1 def test_desc_points_with_singleton_ordered(self): top = self._make_cube([25]) bottom = self._make_cube([15, 5]) result = concatenate([top, bottom]) - self.assertEqual(len(result), 1) + assert len(result) == 1 def test_desc_points_with_singleton_unordered(self): top = self._make_cube([5]) bottom = self._make_cube([25, 15]) result = concatenate([top, bottom]) - self.assertEqual(len(result), 1) + assert len(result) == 1 def test_desc_bounds_with_singleton_ordered(self): top = self._make_cube([25], [[30, 20]]) bottom = self._make_cube([15, 5], [[20, 10], [10, 0]]) result = concatenate([top, bottom]) - self.assertEqual(len(result), 1) + assert len(result) == 1 def test_desc_bounds_with_singleton_unordered(self): top = self._make_cube([5], [[10, 0]]) bottom = self._make_cube([25, 15], [[30, 20], [20, 10]]) result = concatenate([top, bottom]) - self.assertEqual(len(result), 1) + assert len(result) == 1 def test_points_all_singleton(self): top = self._make_cube([5]) bottom = self._make_cube([15]) result1 = concatenate([top, bottom]) result2 = concatenate([bottom, top]) - self.assertEqual(len(result1), 1) - self.assertEqual(len(result2), 1) - self.assertEqual(result1, result2) + assert len(result1) == 1 + assert result1 == result2 def test_asc_bounds_all_singleton(self): top = self._make_cube([5], [0, 10]) bottom = self._make_cube([15], [10, 20]) result1 = concatenate([top, bottom]) result2 = concatenate([bottom, top]) - self.assertEqual(len(result1), 1) - self.assertEqual(len(result2), 1) - self.assertEqual(result1, result2) + assert len(result1) == 1 + assert result1 == result2 def test_desc_bounds_all_singleton(self): top = self._make_cube([5], [10, 0]) bottom = self._make_cube([15], [20, 10]) result1 = concatenate([top, bottom]) result2 = concatenate([bottom, top]) - self.assertEqual(len(result1), 1) - self.assertEqual(len(result2), 1) - self.assertEqual(result1, result2) + assert len(result1) == 1 + assert result1 == result2 -class TestConcatenate__dask(tests.IrisTest): - def build_lazy_cube(self, points, bounds=None, nx=4, aux_coords=False): +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", bounds=bounds) + 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) - if aux_coords: - bounds = np.arange(len(points) * nx * 4).reshape(len(points), nx, 4) - bounds = as_lazy_data(bounds) - aux_coord = iris.coords.AuxCoord(data, var_name="aux_coord", bounds=bounds) - cube.add_aux_coord(aux_coord, (0, 1)) return cube - def test_lazy_concatenate(self): + @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]) - (cube,) = concatenate([c1, c2]) - self.assertTrue(cube.has_lazy_data()) - self.assertFalse(ma.isMaskedArray(cube.data)) + return c1, c2 + + @staticmethod + def add_sample_auxcoord(cube): + # Augment a test cube by adding an aux-coord on the concatenation dimension + n_points, nx = cube.shape + bounds = np.arange(n_points * nx * 4).reshape(n_points, nx, 4) + bounds = as_lazy_data(bounds) + aux_coord = iris.coords.AuxCoord( + cube.core_data(), + bounds=bounds, + var_name="aux_coord", + ) + cube.add_aux_coord(aux_coord, (0, 1)) - def test_lazy_concatenate_aux_coords(self): - c1 = self.build_lazy_cube([1, 2], aux_coords=True) - c2 = self.build_lazy_cube([3, 4, 5], aux_coords=True) + def test_lazy_concatenate(self, sample_lazy_cubes): + (cube,) = concatenate(sample_lazy_cubes) + assert cube.has_lazy_data() + assert not ma.isMaskedArray(cube.data) + + 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]) - self.assertTrue(c1.coord("aux_coord").has_lazy_points()) - self.assertTrue(c1.coord("aux_coord").has_lazy_bounds()) + assert c1.coord("aux_coord").has_lazy_points() + assert c1.coord("aux_coord").has_lazy_bounds() - self.assertTrue(c2.coord("aux_coord").has_lazy_points()) - self.assertTrue(c2.coord("aux_coord").has_lazy_bounds()) + assert c2.coord("aux_coord").has_lazy_points() + assert c2.coord("aux_coord").has_lazy_bounds() - self.assertTrue(result.coord("aux_coord").has_lazy_points()) - self.assertTrue(result.coord("aux_coord").has_lazy_bounds()) + assert result.coord("aux_coord").has_lazy_points() + assert result.coord("aux_coord").has_lazy_bounds() - def test_lazy_concatenate_masked_array_mixed_deferred(self): - c1 = self.build_lazy_cube([1, 2]) - c2 = self.build_lazy_cube([3, 4, 5]) + def test_lazy_concatenate_masked_array_mixed_deferred(self, sample_lazy_cubes): + c1, c2 = sample_lazy_cubes c2.data = np.ma.masked_greater(c2.data, 3) (cube,) = concatenate([c1, c2]) - self.assertTrue(cube.has_lazy_data()) - self.assertTrue(ma.isMaskedArray(cube.data)) - - -if __name__ == "__main__": - tests.main() + assert cube.has_lazy_data() + assert ma.isMaskedArray(cube.data) From 58d541cb116134b98a66dc763a08607f93ba7047 Mon Sep 17 00:00:00 2001 From: Patrick Peglar Date: Mon, 11 Mar 2024 16:01:02 +0000 Subject: [PATCH 2/4] Don't use staticmethod on fixtures. --- lib/iris/tests/unit/concatenate/test_concatenate.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/iris/tests/unit/concatenate/test_concatenate.py b/lib/iris/tests/unit/concatenate/test_concatenate.py index 79953fa9bf..0037a39cd3 100644 --- a/lib/iris/tests/unit/concatenate/test_concatenate.py +++ b/lib/iris/tests/unit/concatenate/test_concatenate.py @@ -18,8 +18,7 @@ class TestEpoch: @pytest.fixture() - @staticmethod - def simple_1d_time_cubes(): + def simple_1d_time_cubes(self): reftimes = [ "hours since 1970-01-01 00:00:00", "hours since 1970-01-01 00:00:00", @@ -51,8 +50,7 @@ def test_concat_1d_with_same_time_units(self, simple_1d_time_cubes): class TestMessages: @pytest.fixture() - @staticmethod - def sample_cubes(): + def sample_cubes(self): # Construct and return a pair of identical cubes data = np.arange(24, dtype=np.float32).reshape(2, 3, 4) cube = iris.cube.Cube(data, standard_name="air_temperature", units="K") From 40cd749cd37101435c27ad266dea8c89875595db Mon Sep 17 00:00:00 2001 From: Patrick Peglar Date: Mon, 11 Mar 2024 16:42:47 +0000 Subject: [PATCH 3/4] Everything in 'TestConcatenate__dask' can use the same sample cubes. --- .../unit/concatenate/test_concatenate.py | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/iris/tests/unit/concatenate/test_concatenate.py b/lib/iris/tests/unit/concatenate/test_concatenate.py index 0037a39cd3..2045c376ce 100644 --- a/lib/iris/tests/unit/concatenate/test_concatenate.py +++ b/lib/iris/tests/unit/concatenate/test_concatenate.py @@ -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 @@ -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]) From 0f36090511805912c91ca00df201cfea959c9850 Mon Sep 17 00:00:00 2001 From: Patrick Peglar Date: Mon, 11 Mar 2024 16:59:40 +0000 Subject: [PATCH 4/4] Spurious parentheses in 'pytest.fixture()' --- lib/iris/tests/unit/concatenate/test_concatenate.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/iris/tests/unit/concatenate/test_concatenate.py b/lib/iris/tests/unit/concatenate/test_concatenate.py index 2045c376ce..577091e9d8 100644 --- a/lib/iris/tests/unit/concatenate/test_concatenate.py +++ b/lib/iris/tests/unit/concatenate/test_concatenate.py @@ -17,7 +17,7 @@ class TestEpoch: - @pytest.fixture() + @pytest.fixture def simple_1d_time_cubes(self): reftimes = [ "hours since 1970-01-01 00:00:00", @@ -49,7 +49,7 @@ def test_concat_1d_with_same_time_units(self, simple_1d_time_cubes): class TestMessages: - @pytest.fixture() + @pytest.fixture def sample_cubes(self): # Construct and return a pair of identical cubes data = np.arange(24, dtype=np.float32).reshape(2, 3, 4) @@ -324,7 +324,7 @@ def test_desc_bounds_all_singleton(self): class TestConcatenate__dask: - @pytest.fixture() + @pytest.fixture def sample_lazy_cubes(self): # Make a pair of concatenatable cubes, with dim points [1, 2] and [3, 4, 5] def build_lazy_cube(points):