Skip to content

Commit 842be13

Browse files
authored
Merge 94abde7 into 9f83a9a
2 parents 9f83a9a + 94abde7 commit 842be13

File tree

7 files changed

+286
-149
lines changed

7 files changed

+286
-149
lines changed

benchmarks/benchmarks/generate_data/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,14 @@ def load_realised():
106106
file loading, but some benchmarks are only meaningful if starting with real
107107
arrays.
108108
"""
109+
from iris.fileformats._nc_load_rules import helpers
109110
from iris.fileformats.netcdf.loader import _get_cf_var_data as pre_patched
110111

111112
def patched(cf_var, filename):
112113
return as_concrete_data(pre_patched(cf_var, filename))
113114

114-
netcdf._get_cf_var_data = patched
115-
yield netcdf
116-
netcdf._get_cf_var_data = pre_patched
115+
netcdf.loader._get_cf_var_data = patched
116+
helpers._get_cf_var_data = patched
117+
yield
118+
netcdf.loader._get_cf_var_data = pre_patched
119+
helpers._get_cf_var_data = pre_patched

benchmarks/benchmarks/generate_data/stock.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ def realistic_4d_w_everything(w_mesh=False, lazy=False) -> iris.cube.Cube:
162162
lazy : bool
163163
If True, the Cube will be returned with all arrays as they would
164164
normally be loaded from file (i.e. most will still be lazy Dask
165-
arrays). If False, all arrays will be realised NumPy arrays.
165+
arrays). If False, all arrays (except derived coordinates) will be
166+
realised NumPy arrays.
166167
167168
"""
168169

docs/src/whatsnew/latest.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ This document explains the changes made to Iris for this release
4848
However, :meth:`~iris.cube.Cube.transpose` will work, as will
4949
:meth:`~iris.cube.Cube.copy`. Note that, ``cube.copy(data=iris.DATALESS)``
5050
will provide a dataless copy of a cube. (:issue:`4447`, :pull:`6253`)
51-
51+
5252
#. `@ESadek-MO`_ added the :mod:`iris.quickplot` ``footer`` kwarg to
5353
render text in the bottom right of the plot figure.
5454
(:issue:`6247`, :pull:`6332`)
55-
55+
5656

5757
🐛 Bugs Fixed
5858
=============
@@ -65,6 +65,9 @@ This document explains the changes made to Iris for this release
6565
older NetCDF formats e.g. ``NETCDF4_CLASSIC`` support a maximum precision of
6666
32-bit. (:issue:`6178`, :pull:`6343`)
6767

68+
#. `@bouweandela`_ fixed handling of masked Dask arrays in
69+
:func:`~iris.util.array_equal`.
70+
6871

6972
💣 Incompatible Changes
7073
=======================
@@ -145,6 +148,8 @@ This document explains the changes made to Iris for this release
145148
#. `@trexfeathers`_ temporarily pinned Sphinx to `<8.2`.
146149
(:pull:`6344`, :issue:`6345`)
147150

151+
#. `@bouweandela`_ fixed a bug in the benchmarking code that caused all benchmarks
152+
to be run with lazy data. (:pull:`6339`)
148153

149154
.. comment
150155
Whatsnew author names (@github name) in alphabetical order. Note that,

lib/iris/coords.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -589,21 +589,22 @@ def __eq__(self, other):
589589
if hasattr(other, "metadata"):
590590
# metadata comparison
591591
eq = self.metadata == other.metadata
592+
593+
# Also consider bounds, if we have them.
594+
# (N.B. though only Coords can ever actually *have* bounds).
595+
if eq and eq is not NotImplemented:
596+
eq = self.has_bounds() is other.has_bounds()
597+
592598
# data values comparison
593599
if eq and eq is not NotImplemented:
594600
eq = iris.util.array_equal(
595601
self._core_values(), other._core_values(), withnans=True
596602
)
597-
598-
# Also consider bounds, if we have them.
599-
# (N.B. though only Coords can ever actually *have* bounds).
600603
if eq and eq is not NotImplemented:
601604
if self.has_bounds() and other.has_bounds():
602605
eq = iris.util.array_equal(
603606
self.core_bounds(), other.core_bounds(), withnans=True
604607
)
605-
else:
606-
eq = not self.has_bounds() and not other.has_bounds()
607608

608609
return eq
609610

lib/iris/tests/unit/concatenate/test_hashing.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import pytest
1010

1111
from iris import _concatenate
12+
from iris.tests.unit.util.test_array_equal import TEST_CASES
13+
from iris.util import array_equal
1214

1315

1416
@pytest.mark.parametrize(
@@ -75,6 +77,20 @@ def test_compute_hashes(a, b, eq):
7577
assert eq == (hashes["a"] == hashes["b"])
7678

7779

80+
@pytest.mark.parametrize(
81+
"a,b",
82+
[
83+
(a, b)
84+
for (a, b, withnans, eq) in TEST_CASES
85+
if isinstance(a, np.ndarray | da.Array) and isinstance(b, np.ndarray | da.Array)
86+
],
87+
)
88+
def test_compute_hashes_vs_array_equal(a, b):
89+
"""Test that hashing give the same answer as `array_equal(withnans=True)`."""
90+
hashes = _concatenate._compute_hashes({"a": a, "b": b})
91+
assert array_equal(a, b, withnans=True) == (hashes["a"] == hashes["b"])
92+
93+
7894
def test_arrayhash_equal_incompatible_chunks_raises():
7995
hash1 = _concatenate._ArrayHash(1, chunks=((1, 1),))
8096
hash2 = _concatenate._ArrayHash(1, chunks=((2,),))

0 commit comments

Comments
 (0)