Skip to content

Commit

Permalink
Fix #5347 (#5349)
Browse files Browse the repository at this point in the history
* fix unit multiplication bug

* docs linkcheck ignore biggus rtd url (#5351)

* add patch whatsnew

---------

Co-authored-by: Bill Little <[email protected]>
  • Loading branch information
stephenworsley and bjlittle authored Jun 15, 2023
1 parent 0937e4f commit eaa7ee4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 19 additions & 1 deletion docs/src/whatsnew/3.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
================

Expand Down Expand Up @@ -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/
.. _Contributor Covenant: https://www.contributor-covenant.org/version/2/1/code_of_conduct/
.. _Distributed: https://distributed.dask.org/en/stable/
3 changes: 2 additions & 1 deletion lib/iris/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions lib/iris/tests/unit/cube/test_Cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand Down

0 comments on commit eaa7ee4

Please sign in to comment.