diff --git a/docs/src/conf.py b/docs/src/conf.py index 312925b4ea..94106b952f 100644 --- a/docs/src/conf.py +++ b/docs/src/conf.py @@ -382,6 +382,7 @@ def _dotv(version): "http://www.esrl.noaa.gov/psd/data/gridded/conventions/cdc_netcdf_standard.shtml", "http://www.nationalarchives.gov.uk/doc/open-government-licence", "https://www.metoffice.gov.uk/", + "https://biggus.readthedocs.io/", ] # list of sources to exclude from the build. diff --git a/docs/src/whatsnew/3.6.rst b/docs/src/whatsnew/3.6.rst index 151c63ef51..543ce7372e 100644 --- a/docs/src/whatsnew/3.6.rst +++ b/docs/src/whatsnew/3.6.rst @@ -55,6 +55,23 @@ This document explains the changes made to Iris for this release or feature requests for improving Iris. Enjoy! +|iris_version| |build_date| +=========================== + +.. dropdown:: |iris_version| Patches + :color: primary + :icon: alert + :animate: fade-in + + The patches in this release of Iris include: + + 🐛 **Bugs Fixed** + + #. `@stephenworsley`_ fixed :meth:`~iris.cube.Cube.convert_units` to allow unit + conversion of lazy data when using a `Distributed`_ scheduler. + (:issue:`5347`, :pull:`5349`) + + 📢 Announcements ================ @@ -180,4 +197,5 @@ This document explains the changes made to Iris for this release .. _PEP-0621: https://peps.python.org/pep-0621/ .. _pypa/build: https://pypa-build.readthedocs.io/en/stable/ .. _NEP29: https://numpy.org/neps/nep-0029-deprecation_policy.html -.. _Contributor Covenant: https://www.contributor-covenant.org/version/2/1/code_of_conduct/ \ No newline at end of file +.. _Contributor Covenant: https://www.contributor-covenant.org/version/2/1/code_of_conduct/ +.. _Distributed: https://distributed.dask.org/en/stable/ diff --git a/lib/iris/cube.py b/lib/iris/cube.py index 7c6fd55c10..44a40cf72b 100644 --- a/lib/iris/cube.py +++ b/lib/iris/cube.py @@ -19,6 +19,7 @@ from xml.dom.minidom import Document import zlib +from cf_units import Unit import dask.array as da import numpy as np import numpy.ma as ma @@ -1144,7 +1145,7 @@ def convert_units(self, unit): ) if self.has_lazy_data(): # Make fixed copies of old + new units for a delayed conversion. - old_unit = self.units + old_unit = Unit(self.units) new_unit = unit pointwise_convert = partial(old_unit.convert, other=new_unit) diff --git a/lib/iris/tests/unit/cube/test_Cube.py b/lib/iris/tests/unit/cube/test_Cube.py index aa9e3b51b1..28fbe429c1 100644 --- a/lib/iris/tests/unit/cube/test_Cube.py +++ b/lib/iris/tests/unit/cube/test_Cube.py @@ -14,6 +14,8 @@ from unittest import mock from cf_units import Unit +import dask.array as da +from distributed import Client import numpy as np import numpy.ma as ma import pytest @@ -3012,6 +3014,14 @@ def test_preserves_lazy(self): self.assertTrue(cube.has_lazy_data()) self.assertArrayAllClose(cube.data, real_data_ft) + def test_unit_multiply(self): + _client = Client() + cube = iris.cube.Cube(da.arange(1), units="m") + cube.units *= "s-1" + cube.convert_units("m s-1") + cube.data + _client.close() + class Test__eq__data(tests.IrisTest): """Partial cube equality testing, for data type only."""