diff --git a/docs/iris/src/whatsnew/3.0.rst b/docs/iris/src/whatsnew/3.0.rst index f0df167cce..a6d1c97036 100644 --- a/docs/iris/src/whatsnew/3.0.rst +++ b/docs/iris/src/whatsnew/3.0.rst @@ -168,6 +168,7 @@ This document explains the changes made to Iris for this release Previously, the first tick label would occasionally be duplicated. This also removes the use of Matplotlib's deprecated ``IndexFormatter``. (:pull:`3857`) +* `@znicholls`_ fixed :meth:`~iris.quickplot._title` to only check ``units.is_time_reference`` if the ``units`` symbol is not used. (:pull:`3902`) .. _whatsnew 3.0 changes: @@ -417,6 +418,9 @@ This document explains the changes made to Iris for this release * `@owena11`_ identified and optimised a bottleneck in ``FieldsFile`` header loading due to the use of :func:`numpy.fromfile`. (:pull:`3791`) +* `@znicholls`_ added a test for plotting with the label being taken from the unit's symbol, see :meth:`~iris.tests.test_quickplot.TestLabels.test_pcolormesh_str_symbol` (:pull:`3902`). + +* `@znicholls`_ made :func:`~iris.tests.idiff.step_over_diffs` robust to hyphens (``-``) in the input path (i.e. the ``result_dir`` argument) (:pull:`3902`). .. _Read the Docs: https://scitools-iris.readthedocs.io/en/latest/ .. _Matplotlib: https://matplotlib.org/ @@ -450,6 +454,7 @@ This document explains the changes made to Iris for this release .. _@rcomer: https://github.com/rcomer .. _@jvegasbsc: https://github.com/jvegasbsc .. _@zklaus: https://github.com/zklaus +.. _@znicholls: https://github.com/znicholls .. _ESMValTool: https://github.com/ESMValGroup/ESMValTool .. _v75: https://cfconventions.org/Data/cf-standard-names/75/build/cf-standard-name-table.html .. _sphinx-panels: https://sphinx-panels.readthedocs.io/en/latest/ diff --git a/lib/iris/quickplot.py b/lib/iris/quickplot.py index 42c0dba46a..350d61b537 100644 --- a/lib/iris/quickplot.py +++ b/lib/iris/quickplot.py @@ -49,7 +49,7 @@ def _title(cube_or_coord, with_units): if _use_symbol(units): units = units.symbol - if units.is_time_reference(): + elif units.is_time_reference(): # iris.plot uses matplotlib.dates.date2num, which is fixed to the below unit. if version.parse(_mpl_version) >= version.parse("3.3"): days_since = "1970-01-01" diff --git a/lib/iris/tests/idiff.py b/lib/iris/tests/idiff.py index e45d8a709e..84a966624f 100755 --- a/lib/iris/tests/idiff.py +++ b/lib/iris/tests/idiff.py @@ -220,7 +220,9 @@ def step_over_diffs(result_dir, action, display=True): count = len(results) for count_index, result_fname in enumerate(results): - key = os.path.splitext("-".join(result_fname.split("-")[1:]))[0] + key = os.path.splitext( + "-".join(result_fname.split("result-")[1:]) + )[0] try: # Calculate the test result perceptual image hash. phash = imagehash.phash( diff --git a/lib/iris/tests/results/imagerepo.json b/lib/iris/tests/results/imagerepo.json index f9430ae9f5..a7fd9e1faf 100644 --- a/lib/iris/tests/results/imagerepo.json +++ b/lib/iris/tests/results/imagerepo.json @@ -908,6 +908,9 @@ "https://scitools.github.io/test-iris-imagehash/images/v4/bb433d4e94a4c6b9c15adaadc1fb6a469c8de43a3e07904e5f016b57984e1ea1.png", "https://scitools.github.io/test-iris-imagehash/images/v4/eea16affc05ab500956e974ac53f3d80925ac03f3f81c07e3fa12da1c27e3f80.png" ], + "iris.tests.test_quickplot.TestLabels.test_pcolormesh_str_symbol.0": [ + "https://scitools.github.io/test-iris-imagehash/images/v4/eea16affc05ab500956e974ac53f3d80925ac03f3f80c07e3fa12da1c27f3f80.png" + ], "iris.tests.test_quickplot.TestQuickplotCoordinatesGiven.test_non_cube_coordinate.0": [ "https://scitools.github.io/test-iris-imagehash/images/v4/fa816a85857a955ae17e957ec57e7a81855fc17e3a81c57e1a813a85c57a1a05.png", "https://scitools.github.io/test-iris-imagehash/images/v4/fe816a85857a957ac07f957ac07f3e80956ac07f3e80c07f3e813e85c07e3f80.png" diff --git a/lib/iris/tests/test_quickplot.py b/lib/iris/tests/test_quickplot.py index cf25324ea7..8abbf48a94 100644 --- a/lib/iris/tests/test_quickplot.py +++ b/lib/iris/tests/test_quickplot.py @@ -201,6 +201,13 @@ def test_pcolormesh(self): self.check_graphic() + def test_pcolormesh_str_symbol(self): + pcube = self._small().copy() + pcube.coords("level_height")[0].units = "centimeters" + qplt.pcolormesh(pcube) + + self.check_graphic() + def test_map(self): cube = self._slice(["grid_latitude", "grid_longitude"]) qplt.contour(cube)