Skip to content

Commit

Permalink
Merge e354202 into 788b6f9
Browse files Browse the repository at this point in the history
  • Loading branch information
bouweandela authored Jun 24, 2024
2 parents 788b6f9 + e354202 commit 085685e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ This document explains the changes made to Iris for this release
#. `@bouweandela`_ made :meth:`iris.cube.Cube.rolling_window` work with lazy
data. (:pull:`5795`)

#. `@bouweandela`_ updated :meth:`iris.cube.CubeList.concatenate` so it keeps
ancillary variables and cell measures lazy. (:pull:`6010`)

🔥 Deprecations
===============

Expand Down
4 changes: 2 additions & 2 deletions lib/iris/_concatenate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ def _build_cell_measures(self):
# Concatenate the data together.
dim = dims.index(self.axis)
data = [
skton.signature.cell_measures_and_dims[i].coord.data
skton.signature.cell_measures_and_dims[i].coord.core_data()
for skton in skeletons
]
data = concatenate_arrays(tuple(data), axis=dim)
Expand Down Expand Up @@ -1185,7 +1185,7 @@ def _build_ancillary_variables(self):
# Concatenate the data together.
dim = dims.index(self.axis)
data = [
skton.signature.ancillary_variables_and_dims[i].coord.data
skton.signature.ancillary_variables_and_dims[i].coord.core_data()
for skton in skeletons
]
data = concatenate_arrays(tuple(data), axis=dim)
Expand Down
21 changes: 21 additions & 0 deletions lib/iris/tests/integration/concatenate/test_concatenate.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import iris.tests as tests # isort:skip

import cf_units
import dask.array as da
import numpy as np

from iris._concatenate import _DerivedCoordAndDims, concatenate
Expand Down Expand Up @@ -157,6 +158,16 @@ def test_ignore_diff_cell_measure(self):
self.assertEqual(len(result), 1)
self.assertEqual(result[0].shape, (4, 2))

def test_lazy_cell_measure(self):
cube_a = self.create_cube()
cube_a.cell_measure("volume").data = da.array([0, 15])
cube_b = cube_a.copy()
cube_b.coord("time").points = [12, 18]

result = concatenate([cube_a, cube_b])
assert len(result) == 1
assert result[0].cell_measure("volume").has_lazy_data()


class Test_cubes_with_ancillary_variables(tests.IrisTest):
def create_cube(self):
Expand Down Expand Up @@ -194,6 +205,16 @@ def test_ignore_diff_ancillary_variables(self):
self.assertEqual(len(result), 1)
self.assertEqual(result[0].shape, (4, 2))

def test_lazy_ancillary_variables(self):
cube_a = self.create_cube()
cube_a.ancillary_variable("quality").data = da.array([0, 15])
cube_b = cube_a.copy()
cube_b.coord("time").points = [12, 18]

result = concatenate([cube_a, cube_b])
assert len(result) == 1
assert result[0].ancillary_variable("quality").has_lazy_data()


class Test_cubes_with_derived_coord(tests.IrisTest):
def create_cube(self):
Expand Down

0 comments on commit 085685e

Please sign in to comment.