Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
17ca4b8
Fix issue where the mask of Dask arrays was ignored and improve tests
bouweandela Feb 19, 2025
7304c8b
Optimize unmasked numpy arrays
bouweandela Feb 20, 2025
66a4ed3
Merge branch 'main' into fix-array-equal-bug
bouweandela Feb 20, 2025
a563bf6
Merge branch 'main' of github.com:scitools/iris into fix-array-equal-bug
bouweandela Feb 24, 2025
d17aa7f
Add whatsnew
bouweandela Feb 26, 2025
6f1c8d4
Merge branch 'main' into fix-array-equal-bug
bouweandela Feb 26, 2025
3949533
Merge branch 'main' of github.com:scitools/iris into fix-array-equal-bug
bouweandela Feb 28, 2025
b9a14ca
Merge branch 'main' of github.com:scitools/iris into fix-array-equal-bug
bouweandela Mar 1, 2025
1abf173
Use dask.array.blockwise for array comparison
bouweandela Mar 2, 2025
a9e1dad
Add whatsnew
bouweandela Feb 26, 2025
c172cf4
Use realized data in benchmarks when requested
bouweandela Feb 26, 2025
fb4b896
Add whatsnew
bouweandela Feb 26, 2025
cfd4852
Faster comparison
bouweandela Mar 4, 2025
59604a2
Avoid flattening arrays
bouweandela Mar 4, 2025
b3344e9
Avoid checking points if one coord has bounds and the other does not …
bouweandela Mar 4, 2025
e43997d
Small simplification
bouweandela Mar 4, 2025
e27eb0c
Merge branch 'fix-array-equal-bug' into bw__array_eq_fix
bouweandela Mar 5, 2025
6fc1665
Add test
bouweandela Mar 5, 2025
092e95f
Use a separate map and reduce operation to avoid running out of memor…
bouweandela Mar 5, 2025
94abde7
Merge branch 'fix-array-equal-bug' into bw__array_eq_fix
bouweandela Mar 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions benchmarks/benchmarks/generate_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,14 @@ def load_realised():
file loading, but some benchmarks are only meaningful if starting with real
arrays.
"""
from iris.fileformats._nc_load_rules import helpers
from iris.fileformats.netcdf.loader import _get_cf_var_data as pre_patched

def patched(cf_var, filename):
return as_concrete_data(pre_patched(cf_var, filename))

netcdf._get_cf_var_data = patched
yield netcdf
netcdf._get_cf_var_data = pre_patched
netcdf.loader._get_cf_var_data = patched
helpers._get_cf_var_data = patched
yield
netcdf.loader._get_cf_var_data = pre_patched
helpers._get_cf_var_data = pre_patched
3 changes: 2 additions & 1 deletion benchmarks/benchmarks/generate_data/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ def realistic_4d_w_everything(w_mesh=False, lazy=False) -> iris.cube.Cube:
lazy : bool
If True, the Cube will be returned with all arrays as they would
normally be loaded from file (i.e. most will still be lazy Dask
arrays). If False, all arrays will be realised NumPy arrays.
arrays). If False, all arrays (except derived coordinates) will be
realised NumPy arrays.

"""

Expand Down
9 changes: 7 additions & 2 deletions docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ This document explains the changes made to Iris for this release
However, :meth:`~iris.cube.Cube.transpose` will work, as will
:meth:`~iris.cube.Cube.copy`. Note that, ``cube.copy(data=iris.DATALESS)``
will provide a dataless copy of a cube. (:issue:`4447`, :pull:`6253`)

#. `@ESadek-MO`_ added the :mod:`iris.quickplot` ``footer`` kwarg to
render text in the bottom right of the plot figure.
(:issue:`6247`, :pull:`6332`)


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

#. `@bouweandela`_ fixed handling of masked Dask arrays in
:func:`~iris.util.array_equal`.


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

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

.. comment
Whatsnew author names (@github name) in alphabetical order. Note that,
Expand Down
11 changes: 6 additions & 5 deletions lib/iris/coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,21 +589,22 @@ def __eq__(self, other):
if hasattr(other, "metadata"):
# metadata comparison
eq = self.metadata == other.metadata

# Also consider bounds, if we have them.
# (N.B. though only Coords can ever actually *have* bounds).
if eq and eq is not NotImplemented:
eq = self.has_bounds() is other.has_bounds()

# data values comparison
if eq and eq is not NotImplemented:
eq = iris.util.array_equal(
self._core_values(), other._core_values(), withnans=True
)

# Also consider bounds, if we have them.
# (N.B. though only Coords can ever actually *have* bounds).
if eq and eq is not NotImplemented:
if self.has_bounds() and other.has_bounds():
eq = iris.util.array_equal(
self.core_bounds(), other.core_bounds(), withnans=True
)
else:
eq = not self.has_bounds() and not other.has_bounds()

return eq

Expand Down
16 changes: 16 additions & 0 deletions lib/iris/tests/unit/concatenate/test_hashing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import pytest

from iris import _concatenate
from iris.tests.unit.util.test_array_equal import TEST_CASES
from iris.util import array_equal


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


@pytest.mark.parametrize(
"a,b",
[
(a, b)
for (a, b, withnans, eq) in TEST_CASES
if isinstance(a, np.ndarray | da.Array) and isinstance(b, np.ndarray | da.Array)
],
)
def test_compute_hashes_vs_array_equal(a, b):
"""Test that hashing give the same answer as `array_equal(withnans=True)`."""
hashes = _concatenate._compute_hashes({"a": a, "b": b})
assert array_equal(a, b, withnans=True) == (hashes["a"] == hashes["b"])


def test_arrayhash_equal_incompatible_chunks_raises():
hash1 = _concatenate._ArrayHash(1, chunks=((1, 1),))
hash2 = _concatenate._ArrayHash(1, chunks=((2,),))
Expand Down
Loading
Loading