Skip to content

Commit

Permalink
Merge branch 'SciTools:main' into shapefile_masking
Browse files Browse the repository at this point in the history
  • Loading branch information
acchamber authored Feb 13, 2024
2 parents 84a8212 + 117dd76 commit bf3c720
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ repos:
- id: no-commit-to-branch

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.14"
rev: "v0.2.1"
hooks:
- id: ruff
types: [file, python]
Expand Down
16 changes: 15 additions & 1 deletion docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ This document explains the changes made to Iris for this release
💣 Incompatible Changes
=======================

#. N/A
#. `@bouweandela`_ and `@trexfeathers`_ (reviewer) updated :class:`~iris.cube.Cube`
comparison so equality is now possible between cubes with data containing a
:obj:`numpy.nan`. e.g. ``Cube([np.nan, 1.0]) == Cube([np.nan, 1.0])`` will now
evaluate to :obj:`True`, while previously this would have been :obj:`False`. (:pull:`5713`)


🚀 Performance Enhancements
Expand All @@ -119,6 +122,9 @@ This document explains the changes made to Iris for this release

#. `@bouweandela`_ made comparing coordinates and arrays to themselves faster. (:pull:`5691`)

#. `@bouweandela`_ and `@trexfeathers`_ (reviewer) made comparing cubes to
themselves faster. (:pull:`5713`)


🔥 Deprecations
===============
Expand Down Expand Up @@ -227,6 +233,13 @@ This document explains the changes made to Iris for this release

#. `@bjlittle`_ replaced `black`_ with `ruff`_. (:pull:`5634`)

#. `@tkknight`_ and `@bjlittle`_ (reviewer) updated codebase to be compliant with
almost all of the rules for `ruff pydocstyle`_.
(https://github.com/SciTools/iris/issues/5625#issuecomment-1859159734)

#. `@tkknight`_ and `@bjlittle`_ (reviewer) updated codebase to ensure docstrings
that are not covered by the ruff checks, are consistent with numpydocstyle.
(:issue:`4721`)

.. comment
Whatsnew author names (@github name) in alphabetical order. Note that,
Expand All @@ -247,3 +260,4 @@ This document explains the changes made to Iris for this release
.. _NEP29 Drop Schedule: https://numpy.org/neps/nep-0029-deprecation_policy.html#drop-schedule
.. _codespell: https://github.com/codespell-project/codespell
.. _split attributes project: https://github.com/orgs/SciTools/projects/5?pane=info
.. _ruff pydocstyle: https://docs.astral.sh/ruff/rules/#pydocstyle-d
2 changes: 1 addition & 1 deletion lib/iris/analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1577,7 +1577,7 @@ def _lazy_max_run(array, axis=-1, **kwargs):
stepped_run_lengths = da.reductions.cumreduction(
np.maximum.accumulate,
np.maximum,
np.NINF,
-np.inf,
run_totals,
axis=axis,
dtype=cum_sum.dtype,
Expand Down
11 changes: 10 additions & 1 deletion lib/iris/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -3824,6 +3824,9 @@ def _deepcopy(self, memo, data=None):

# START OPERATOR OVERLOADS
def __eq__(self, other):
if other is self:
return True

result = NotImplemented

if isinstance(other, Cube):
Expand Down Expand Up @@ -3862,7 +3865,13 @@ def __eq__(self, other):
if result:
# TODO: why do we use allclose() here, but strict equality in
# _DimensionalMetadata (via util.array_equal())?
result = da.allclose(self.core_data(), other.core_data()).compute()
result = bool(
np.allclose(
self.core_data(),
other.core_data(),
equal_nan=True,
)
)
return result

# Must supply __ne__, Python does not defer to __eq__ for negative equality
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/fileformats/netcdf/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ def set(
apply the `dimension_chunksizes` controls only to these variables,
or when building :class:`~iris.cube.Cube` from these data variables.
If ``None``, settings apply to all loaded variables.
dimension_chunksizes : dict of {str: int}
**dimension_chunksizes : dict of {str: int}
Kwargs specifying chunksizes for dimensions of file variables.
Each key-value pair defines a chunk size for a named file
dimension, e.g. ``{'time': 10, 'model_levels':1}``.
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/test_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def test_numpy_int_equality(self):

def test_numpy_float_equality(self):
dtypes = (
np.float_,
np.float64,
np.float16,
np.float32,
np.float64,
Expand Down
9 changes: 9 additions & 0 deletions lib/iris/tests/unit/cube/test_Cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -2841,11 +2841,20 @@ def test_unit_multiply(self):
class Test__eq__data(tests.IrisTest):
"""Partial cube equality testing, for data type only."""

def test_cube_identical_to_itself(self):
cube = Cube([1.0])
self.assertTrue(cube == cube)

def test_data_float_eq(self):
cube1 = Cube([1.0])
cube2 = Cube([1.0])
self.assertTrue(cube1 == cube2)

def test_data_float_nan_eq(self):
cube1 = Cube([np.nan, 1.0])
cube2 = Cube([np.nan, 1.0])
self.assertTrue(cube1 == cube2)

def test_data_float_eqtol(self):
val1 = np.array(1.0, dtype=np.float32)
# NOTE: Since v2.3, Iris uses "allclose". Prior to that we used
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/unit/plot/test_contourf.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_skip_contour(self):
def test_apply_contour_nans(self):
# Presence of nans should not prevent contours being added.
cube = simple_2d()
cube.data = cube.data.astype(np.float_)
cube.data = cube.data.astype(np.float64)
cube.data[0, 0] = np.nan

levels = [2, 4, 6, 8]
Expand Down
16 changes: 8 additions & 8 deletions requirements/locks/py310-linux-64.lock
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ https://conda.anaconda.org/conda-forge/linux-64/libedit-3.1.20191231-he28a2e2_2.
https://conda.anaconda.org/conda-forge/linux-64/libgfortran-ng-13.2.0-h69a702a_5.conda#e73e9cfd1191783392131e6238bdb3e9
https://conda.anaconda.org/conda-forge/linux-64/libnghttp2-1.58.0-h47da74e_1.conda#700ac6ea6d53d5510591c4344d5c989a
https://conda.anaconda.org/conda-forge/linux-64/libpng-1.6.42-h2797004_0.conda#d67729828dc6ff7ba44a61062ad79880
https://conda.anaconda.org/conda-forge/linux-64/libsqlite-3.44.2-h2797004_0.conda#3b6a9f225c3dbe0d24f4fedd4625c5bf
https://conda.anaconda.org/conda-forge/linux-64/libsqlite-3.45.1-h2797004_0.conda#fc4ccadfbf6d4784de88c41704792562
https://conda.anaconda.org/conda-forge/linux-64/libssh2-1.11.0-h0841786_0.conda#1f5a58e686b13bcfde88b93f547d23fe
https://conda.anaconda.org/conda-forge/linux-64/libudunits2-2.2.28-h40f5838_3.conda#4bdace082e911a3e1f1f0b721bed5b56
https://conda.anaconda.org/conda-forge/linux-64/libxcb-1.15-h0b41bf4_0.conda#33277193f5b92bad9fdd230eb700929c
https://conda.anaconda.org/conda-forge/linux-64/libxml2-2.12.4-h232c23b_1.conda#53e951fab78d7e3bab40745f7b3d1620
https://conda.anaconda.org/conda-forge/linux-64/libxml2-2.12.5-h232c23b_0.conda#c442ebfda7a475f5e78f1c8e45f1e919
https://conda.anaconda.org/conda-forge/linux-64/libzip-1.10.1-h2629f0a_3.conda#ac79812548e7e8cf61f7b0abdef01d3b
https://conda.anaconda.org/conda-forge/linux-64/pcre2-10.42-hcad00b1_0.conda#679c8961826aa4b50653bce17ee52abe
https://conda.anaconda.org/conda-forge/linux-64/readline-8.2-h8228510_1.conda#47d31b792659ce70f470b5c82fdfb7a4
Expand All @@ -86,7 +86,7 @@ https://conda.anaconda.org/conda-forge/linux-64/libglib-2.78.3-h783c2da_0.conda#
https://conda.anaconda.org/conda-forge/linux-64/libopenblas-0.3.26-pthreads_h413a1c8_0.conda#760ae35415f5ba8b15d09df5afe8b23a
https://conda.anaconda.org/conda-forge/linux-64/libtiff-4.6.0-ha9c0a0a_2.conda#55ed21669b2015f77c180feb1dd41930
https://conda.anaconda.org/conda-forge/linux-64/python-3.10.13-hd12c33a_1_cpython.conda#ed38140af93f81319ebc472fbcf16cca
https://conda.anaconda.org/conda-forge/linux-64/sqlite-3.44.2-h2c6b66d_0.conda#4f2892c672829693fd978d065db4e8be
https://conda.anaconda.org/conda-forge/linux-64/sqlite-3.45.1-h2c6b66d_0.conda#93acf31b379acebada263b9bce3dc6ed
https://conda.anaconda.org/conda-forge/linux-64/udunits2-2.2.28-h40f5838_3.conda#6bb8deb138f87c9d48320ac21b87e7a1
https://conda.anaconda.org/conda-forge/linux-64/xorg-libx11-1.8.7-h8ee46fc_0.conda#49e482d882669206653b095f5206c05b
https://conda.anaconda.org/conda-forge/noarch/alabaster-0.7.16-pyhd8ed1ab_0.conda#def531a3ac77b7fb8c21d17bb5d0badb
Expand All @@ -95,7 +95,7 @@ https://conda.anaconda.org/conda-forge/noarch/asv_runner-0.1.0-pyhd8ed1ab_0.cond
https://conda.anaconda.org/conda-forge/linux-64/atk-1.0-2.38.0-hd4edc92_1.tar.bz2#6c72ec3e660a51736913ef6ea68c454b
https://conda.anaconda.org/conda-forge/linux-64/brotli-1.1.0-hd590300_1.conda#f27a24d46e3ea7b70a1f98e50c62508f
https://conda.anaconda.org/conda-forge/linux-64/brotli-python-1.1.0-py310hc6cd4ac_1.conda#1f95722c94f00b69af69a066c7433714
https://conda.anaconda.org/conda-forge/noarch/certifi-2023.11.17-pyhd8ed1ab_0.conda#2011bcf45376341dd1d690263fdbc789
https://conda.anaconda.org/conda-forge/noarch/certifi-2024.2.2-pyhd8ed1ab_0.conda#0876280e409658fc6f9e75d035960333
https://conda.anaconda.org/conda-forge/noarch/cfgv-3.3.1-pyhd8ed1ab_0.tar.bz2#ebb5f5f7dc4f1a3780ef7ea7738db08c
https://conda.anaconda.org/conda-forge/noarch/charset-normalizer-3.3.2-pyhd8ed1ab_0.conda#7f4a9e3fcff3f6356ae99244a014da6a
https://conda.anaconda.org/conda-forge/noarch/click-8.1.7-unix_pyh707e725_0.conda#f3ad426304898027fc619827ff428eca
Expand All @@ -109,7 +109,7 @@ https://conda.anaconda.org/conda-forge/noarch/exceptiongroup-1.2.0-pyhd8ed1ab_2.
https://conda.anaconda.org/conda-forge/noarch/execnet-2.0.2-pyhd8ed1ab_0.conda#67de0d8241e1060a479e3c37793e26f9
https://conda.anaconda.org/conda-forge/noarch/filelock-3.13.1-pyhd8ed1ab_0.conda#0c1729b74a8152fde6a38ba0a2ab9f45
https://conda.anaconda.org/conda-forge/linux-64/fontconfig-2.14.2-h14ed4e7_0.conda#0f69b688f52ff6da70bccb7ff7001d1d
https://conda.anaconda.org/conda-forge/noarch/fsspec-2023.12.2-pyhca7485f_0.conda#bf40f2a8835b78b1f91083d306b493d2
https://conda.anaconda.org/conda-forge/noarch/fsspec-2024.2.0-pyhca7485f_0.conda#fad86b90138cf5d82c6f5a2ed6e683d9
https://conda.anaconda.org/conda-forge/linux-64/gdk-pixbuf-2.42.10-h829c605_4.conda#252a696860674caf7a855e16f680d63a
https://conda.anaconda.org/conda-forge/linux-64/gts-0.7.6-h977cf35_4.conda#4d8df0b0db060d33c9a702ada998a8fe
https://conda.anaconda.org/conda-forge/noarch/idna-3.6-pyhd8ed1ab_0.conda#1a76f09108576397c41c0b0c5bd84134
Expand Down Expand Up @@ -164,7 +164,7 @@ https://conda.anaconda.org/conda-forge/linux-64/cairo-1.18.0-h3faef2a_0.conda#f9
https://conda.anaconda.org/conda-forge/linux-64/cffi-1.16.0-py310h2fee648_0.conda#45846a970e71ac98fd327da5d40a0a2c
https://conda.anaconda.org/conda-forge/linux-64/coverage-7.4.1-py310h2372a71_0.conda#b2de1af90e44849451c9808312f964ae
https://conda.anaconda.org/conda-forge/linux-64/cytoolz-0.12.3-py310h2372a71_0.conda#21362970a6fea90ca507c253c20465f2
https://conda.anaconda.org/conda-forge/linux-64/fonttools-4.47.2-py310h2372a71_0.conda#0688fca50c84de6ff0df1c6440941e0e
https://conda.anaconda.org/conda-forge/linux-64/fonttools-4.48.1-py310h2372a71_0.conda#480ff621e839c5f80a52975b167500d2
https://conda.anaconda.org/conda-forge/linux-64/hdf5-1.14.3-nompi_h4f84152_100.conda#d471a5c3abc984b662d9bae3bb7fd8a5
https://conda.anaconda.org/conda-forge/noarch/importlib-metadata-7.0.1-pyha770c72_0.conda#746623a787e06191d80a2133e5daff17
https://conda.anaconda.org/conda-forge/noarch/jinja2-3.1.3-pyhd8ed1ab_0.conda#e7d8df6509ba635247ff9aea31134262
Expand All @@ -174,7 +174,7 @@ https://conda.anaconda.org/conda-forge/linux-64/liblapack-3.9.0-21_linux64_openb
https://conda.anaconda.org/conda-forge/noarch/nodeenv-1.8.0-pyhd8ed1ab_0.conda#2a75b296096adabbabadd5e9782e5fcc
https://conda.anaconda.org/conda-forge/noarch/partd-1.4.1-pyhd8ed1ab_0.conda#acf4b7c0bcd5fa3b0e05801c4d2accd6
https://conda.anaconda.org/conda-forge/linux-64/pillow-10.2.0-py310h01dd4db_0.conda#9ec32d0d90f7670eb29bbba18299cf29
https://conda.anaconda.org/conda-forge/noarch/pip-23.3.2-pyhd8ed1ab_0.conda#8591c748f98dcc02253003533bc2e4b1
https://conda.anaconda.org/conda-forge/noarch/pip-24.0-pyhd8ed1ab_0.conda#f586ac1e56c8638b64f9c8122a7b8a67
https://conda.anaconda.org/conda-forge/linux-64/proj-9.3.1-h1d62c97_0.conda#44ec51d0857d9be26158bb85caa74fdb
https://conda.anaconda.org/conda-forge/noarch/pytest-8.0.0-pyhd8ed1ab_0.conda#5ba1cc5b924226349d4a49fb547b7579
https://conda.anaconda.org/conda-forge/noarch/python-dateutil-2.8.2-pyhd8ed1ab_0.tar.bz2#dd999d1cc9f79e67dbb855c8924c7984
Expand All @@ -184,7 +184,7 @@ https://conda.anaconda.org/conda-forge/noarch/virtualenv-20.25.0-pyhd8ed1ab_0.co
https://conda.anaconda.org/conda-forge/linux-64/harfbuzz-8.3.0-h3d44ed6_0.conda#5a6f6c00ef982a9bc83558d9ac8f64a0
https://conda.anaconda.org/conda-forge/noarch/importlib_metadata-7.0.1-hd8ed1ab_0.conda#4a2f43a20fa404b998859c6a470ba316
https://conda.anaconda.org/conda-forge/linux-64/libnetcdf-4.9.2-nompi_h9612171_113.conda#b2414908e43c442ddc68e6148774a304
https://conda.anaconda.org/conda-forge/linux-64/numpy-1.26.3-py310hb13e2d6_0.conda#e5e9c6f112d581cdf465b8ca861cb14f
https://conda.anaconda.org/conda-forge/linux-64/numpy-1.26.4-py310hb13e2d6_0.conda#6593de64c935768b6bad3e19b3e978be
https://conda.anaconda.org/conda-forge/noarch/pbr-6.0.0-pyhd8ed1ab_0.conda#8dbab5ba746ed14aa32cb232dc437f8f
https://conda.anaconda.org/conda-forge/linux-64/pyproj-3.6.1-py310hd5c30f3_5.conda#dc2ee770a2299307f3c127af79160d25
https://conda.anaconda.org/conda-forge/noarch/pytest-cov-4.1.0-pyhd8ed1ab_0.conda#06eb685a3a0b146347a58dda979485da
Expand Down
Loading

0 comments on commit bf3c720

Please sign in to comment.