Skip to content

Commit

Permalink
Merge branch 'main' into theme_play
Browse files Browse the repository at this point in the history
* main: (23 commits)
  Suggest type hinting (SciTools#4390)
  area weight regrid test fixes (SciTools#4432)
  Update latest.rst (SciTools#4425)
  Added @wjbenfold to the core dev list (SciTools#4423)
  Removed addition of period from wrap_lons. (SciTools#4421)
  Add release docs sections describing the role of a Release Manager (SciTools#4413)
  Subset should always return None if no value matches are found (SciTools#4417)
  What's new for SciTools#4400 (SciTools#4422)
  `iris.analysis.AreaWeighted` regrid speedup (SciTools#4400)
  [pre-commit.ci] pre-commit autoupdate (SciTools#4419)
  Remove newline to satisfy setuptools (SciTools#4418)
  Updated environment lockfiles (SciTools#4416)
  NAME loader fixes (SciTools#4411)
  Updated whatsnew for PR 4402 (SciTools#4410)
  Support test data in benchmark workflows (SciTools#4402)
  What's new for pr 4387 (SciTools#4405)
  Make concat mismatch warning for scalar coords more accurate (SciTools#4387)
  Added line to latest release notes for updates to pp_save_rules.py (SciTools#4404)
  Update pp_save_rules.py (SciTools#4391)
  [pre-commit.ci] pre-commit autoupdate (SciTools#4403)
  ...
  • Loading branch information
tkknight committed Nov 25, 2021
2 parents 57f60da + 6d24b30 commit f5a2841
Show file tree
Hide file tree
Showing 36 changed files with 1,044 additions and 349 deletions.
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ env:
# Conda packages to be installed.
CONDA_CACHE_PACKAGES: "nox pip"
# Git commit hash for iris test data.
IRIS_TEST_DATA_VERSION: "2.4"
IRIS_TEST_DATA_VERSION: "2.5"
# Base directory for the iris-test-data.
IRIS_TEST_DATA_DIR: ${HOME}/iris-test-data

Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ jobs:
benchmark:
runs-on: ubuntu-latest

env:
IRIS_TEST_DATA_LOC_PATH: benchmarks
IRIS_TEST_DATA_PATH: benchmarks/iris-test-data
IRIS_TEST_DATA_VERSION: "2.5"
# Lets us manually bump the cache to rebuild
TEST_DATA_CACHE_BUILD: "2"

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
Expand Down Expand Up @@ -38,9 +45,31 @@ jobs:
key: ${{ runner.os }}-${{ github.sha }}
restore-keys: ${{ runner.os }}

- name: Cache test data directory
id: cache-test-data
uses: actions/cache@v2
with:
path: |
${{ env.IRIS_TEST_DATA_PATH }}
key:
test-data-${{ env.IRIS_TEST_DATA_VERSION }}-${{ env.TEST_DATA_CACHE_BUILD }}

- name: Fetch the test data
if: steps.cache-test-data.outputs.cache-hit != 'true'
run: |
wget --quiet https://github.com/SciTools/iris-test-data/archive/v${IRIS_TEST_DATA_VERSION}.zip -O iris-test-data.zip
unzip -q iris-test-data.zip
mkdir --parents ${GITHUB_WORKSPACE}/${IRIS_TEST_DATA_LOC_PATH}
mv iris-test-data-${IRIS_TEST_DATA_VERSION} ${GITHUB_WORKSPACE}/${IRIS_TEST_DATA_PATH}
- name: Set test data var
run: |
echo "OVERRIDE_TEST_DATA_REPOSITORY=${GITHUB_WORKSPACE}/${IRIS_TEST_DATA_PATH}/test_data" >> $GITHUB_ENV
- name: Run CI benchmarks
run: |
mkdir --parents benchmarks/.asv
set -o pipefail
nox --session="benchmarks(ci compare)" | tee benchmarks/.asv/ci_compare.txt
- name: Archive asv results
Expand Down
5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ files: |
noxfile\.py|
setup\.py|
docs\/.+\.py|
lib\/.+\.py
lib\/.+\.py|
benchmarks\/.+\.py
)
minimum_pre_commit_version: 1.21.0

Expand Down Expand Up @@ -42,7 +43,7 @@ repos:
args: [--config=./setup.cfg]

- repo: https://github.com/pycqa/isort
rev: 5.9.3
rev: 5.10.1
hooks:
- id: isort
types: [file, python]
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmarks/metadata_manager_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"""

from iris.common import (
metadata_manager_factory,
AncillaryVariableMetadata,
BaseMetadata,
CellMeasureMetadata,
CoordMetadata,
CubeMetadata,
DimCoordMetadata,
metadata_manager_factory,
)


Expand Down
1 change: 0 additions & 1 deletion benchmarks/benchmarks/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from iris import coords
from iris.common.metadata import AncillaryVariableMetadata


LONG_NAME = "air temperature"
STANDARD_NAME = "air_temperature"
VAR_NAME = "air_temp"
Expand Down
40 changes: 40 additions & 0 deletions benchmarks/benchmarks/regridding.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright Iris contributors
#
# This file is part of Iris and is released under the LGPL license.
# See COPYING and COPYING.LESSER in the root of the repository for full
# licensing details.
"""
Regridding benchmark test
"""

# import iris tests first so that some things can be initialised before
# importing anything else
from iris import tests # isort:skip

import iris
from iris.analysis import AreaWeighted


class HorizontalChunkedRegridding:
def setup(self) -> None:
# Prepare a cube and a template

cube_file_path = tests.get_data_path(
["NetCDF", "regrid", "regrid_xyt.nc"]
)
self.cube = iris.load_cube(cube_file_path)

template_file_path = tests.get_data_path(
["NetCDF", "regrid", "regrid_template_global_latlon.nc"]
)
self.template_cube = iris.load_cube(template_file_path)

# Chunked data makes the regridder run repeatedly
self.cube.data = self.cube.lazy_data().rechunk((1, -1, -1))

def time_regrid_area_w(self) -> None:
# Regrid the cube onto the template.
out = self.cube.regrid(self.template_cube, AreaWeighted())
# Realise the data
out.data
4 changes: 2 additions & 2 deletions benchmarks/nox_asv_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
from shutil import copy2, copytree
from tempfile import TemporaryDirectory

from asv import util as asv_util
from asv.config import Config
from asv.console import log
from asv.environment import get_env_name
from asv.plugins.conda import Conda, _find_conda
from asv.repo import get_repo, Repo
from asv import util as asv_util
from asv.repo import Repo, get_repo


class NoxConda(Conda):
Expand Down
8 changes: 8 additions & 0 deletions docs/src/developers_guide/contributing_code_formatting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,13 @@ will look similar to::
.. note:: You can also run `black`_ and `flake8`_ manually. Please see the
their officially documentation for more information.

Type Hinting
------------
Iris is gradually adding
`type hints <https://docs.python.org/3/library/typing.html>`_ into the
codebase. The reviewer will look for type hints in a pull request; if you're
not confident with these, feel free to work together with the reviewer to
add/improve them.


.. _pre-commit: https://pre-commit.com/
16 changes: 16 additions & 0 deletions docs/src/developers_guide/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ The summary below is of the main areas that constitute the release. The final
section details the :ref:`iris_development_releases_steps` to take.


.. _release_manager:

Release Manager
---------------
A Release Manager will be nominated for each release of Iris. This role involves:

* deciding which features and bug fixes should be included in the release
* managing the project board for the release
* using a `GitHub Releases Discussion Forum`_ for documenting intent and capturing any
discussion about the release

The Release Manager will make the release, ensuring that all the steps outlined
on this page are completed.


Before Release
--------------

Expand Down Expand Up @@ -243,6 +258,7 @@ Post Release Steps

.. _SciTools/iris: https://github.com/SciTools/iris
.. _tag on the SciTools/Iris: https://github.com/SciTools/iris/releases
.. _GitHub Releases Discussion Forum: https://github.com/SciTools/iris/discussions/categories/releases
.. _conda-forge Anaconda channel: https://anaconda.org/conda-forge/iris
.. _conda-forge iris-feedstock: https://github.com/conda-forge/iris-feedstock
.. _CFEP-05: https://github.com/conda-forge/cfep/blob/master/cfep-05.md
Expand Down
51 changes: 48 additions & 3 deletions docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ This document explains the changes made to Iris for this release
📢 Announcements
================

#. Welcome to `@wjbenfold`_, `@tinyendian`_ and `@larsbarring`_ who made their
first contributions to Iris. The first of many we hope!
#. Welcome to `@wjbenfold`_, `@tinyendian`_, `@larsbarring`_, `@akuhnregnier`_
and `@bsherratt`_ who made their first contributions to Iris. The first of many we hope!
#. Congratulations to `@wjbenfold`_ who has become a core developer for Iris! 🎉


✨ Features
Expand Down Expand Up @@ -81,15 +82,24 @@ This document explains the changes made to Iris for this release
:attr:`~iris.experimental.ugrid.mesh.Connectivity.indices` under the
`UGRID`_ model. (:pull:`4375`)

#. `@bsherratt`_ added a `threshold` parameter to
:meth:`~iris.cube.Cube.intersection` (:pull:`4363`)

#. `@wjbenfold`_ added test data to ci benchmarks so that it is accessible to
benchmark scripts. Also added a regridding benchmark that uses this data
(:pull:`4402`)


🐛 Bugs Fixed
=============


#. `@rcomer`_ fixed :meth:`~iris.cube.Cube.intersection` for special cases where
one cell's bounds align with the requested maximum and negative minimum, fixing
:issue:`4221`. (:pull:`4278`)

#. `@bsherratt`_ fixed further edge cases in
:meth:`~iris.cube.Cube.intersection`, including :issue:`3698` (:pull:`4363`)

#. `@tinyendian`_ fixed the error message produced by :meth:`~iris.cube.CubeList.concatenate_cube`
when a cube list contains cubes with different names, which will no longer report
"Cube names differ: var1 != var1" if var1 appears multiple times in the list
Expand All @@ -98,6 +108,25 @@ This document explains the changes made to Iris for this release
#. `@larsbarring`_ fixed :class:`~iris.coord_systems.GeoCS` to handle spherical ellipsoid
parameter inverse_flattening = 0 (:issue: `4146`, :pull:`4348`)

#. `@pdearnshaw`_ fixed an error in the call to :class:`cftime.datetime` in
:mod:`~iris.fileformats.pp_save_rules` that prevented the saving to PP of climate
means for DJF (:pull:`4391`)

#. `@wjbenfold`_ improved the error message for failure of :meth:`~iris.cube.CubeList.concatenate`
to indicate that the value of a scalar coordinate may be mismatched, rather than the metadata
(:issue:`4096`, :pull:`4387`)

#. `@bsherratt`_ fixed a regression to the NAME file loader introduced in 3.0.4,
as well as some long-standing bugs with vertical coordinates and number
formats. (:pull:`4411`)

#. `@rcomer`_ fixed :meth:`~iris.cube.Cube.subset` to alway return ``None`` if
no value match is found. (:pull:`4417`)

#. `@wjbenfold`_ resolved an issue that previously caused regridding with lazy
data to take significantly longer than with real data. Relevant benchmark
shows a time decrease from >10s to 625ms. (:issue:`4280`, :pull:`4400`)


💣 Incompatible Changes
=======================
Expand Down Expand Up @@ -149,6 +178,12 @@ This document explains the changes made to Iris for this release
#. `@trexfeathers`_ added more detail on making `iris-test-data`_ available
during :ref:`developer_running_tests`. (:pull:`4359`)

#. `@lbdreyer`_ added a section to the release documentation outlining the role
of the :ref:`release_manager`. (:pull:`4413`)

#. `@trexfeathers`_ encouraged contributors to include type hinting in code
they are working on - :ref:`code_formatting`. (:pull:`4390`)


💼 Internal
===========
Expand Down Expand Up @@ -183,11 +218,21 @@ This document explains the changes made to Iris for this release
#. `@rcomer`_ modified a NetCDF saver test to prevent it triggering a numpy
deprecation warning. (:issue:`4374`, :pull:`4376`)

#. `@akuhnregnier`_ removed addition of period from
:func:`~iris.analysis.cartography.wrap_lons` and updated affected tests
using assertArrayAllClose following :issue:`3993`.
(:pull:`4421`)

#. `@rcomer`_ applied minor fixes to some regridding tests. (:pull:`4432`)

.. comment
Whatsnew author names (@github name) in alphabetical order. Note that,
core dev names are automatically included by the common_links.inc:
.. _@akuhnregnier: https://github.com/akuhnregnier
.. _@bsherratt: https://github.com/bsherratt
.. _@larsbarring: https://github.com/larsbarring
.. _@pdearnshaw: https://github.com/pdearnshaw
.. _@tinyendian: https://github.com/tinyendian

.. comment
Expand Down
18 changes: 12 additions & 6 deletions lib/iris/_concatenate.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def meta_key_func(dm):
av_and_dims = _CoordAndDims(av, tuple(dims))
self.ancillary_variables_and_dims.append(av_and_dims)

def _coordinate_differences(self, other, attr):
def _coordinate_differences(self, other, attr, reason="metadata"):
"""
Determine the names of the coordinates that differ between `self` and
`other` for a coordinate attribute on a _CubeSignature.
Expand All @@ -451,12 +451,16 @@ def _coordinate_differences(self, other, attr):
The _CubeSignature attribute within which differences exist
between `self` and `other`.
* reason (string):
The reason to give for mismatch (function is normally, but not
always, testing metadata)
Returns:
Tuple of a descriptive error message and the names of coordinates
Tuple of a descriptive error message and the names of attributes
that differ between `self` and `other`.
"""
# Set up {name: coord_metadata} dictionaries.
# Set up {name: attribute} dictionaries.
self_dict = {x.name(): x for x in getattr(self, attr)}
other_dict = {x.name(): x for x in getattr(other, attr)}
if len(self_dict) == 0:
Expand All @@ -466,7 +470,7 @@ def _coordinate_differences(self, other, attr):
self_names = sorted(self_dict.keys())
other_names = sorted(other_dict.keys())

# Compare coord metadata.
# Compare coord attributes.
if len(self_names) != len(other_names) or self_names != other_names:
result = ("", ", ".join(self_names), ", ".join(other_names))
else:
Expand All @@ -476,7 +480,7 @@ def _coordinate_differences(self, other, attr):
if self_value != other_value:
diff_names.append(self_key)
result = (
" metadata",
" " + reason,
", ".join(diff_names),
", ".join(diff_names),
)
Expand Down Expand Up @@ -542,7 +546,9 @@ def match(self, other, error_on_mismatch):
)
# Check scalar coordinates.
if self.scalar_coords != other.scalar_coords:
differences = self._coordinate_differences(other, "scalar_coords")
differences = self._coordinate_differences(
other, "scalar_coords", reason="values or metadata"
)
msgs.append(
msg_template.format("Scalar coordinates", *differences)
)
Expand Down
2 changes: 2 additions & 0 deletions lib/iris/analysis/_area_weighted.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def __init__(self, src_grid_cube, target_grid_cube, mdtol=1):
self.meshgrid_x,
self.meshgrid_y,
self.weights_info,
self.index_info,
) = _regrid_info

def __call__(self, cube):
Expand Down Expand Up @@ -124,6 +125,7 @@ def __call__(self, cube):
self.meshgrid_x,
self.meshgrid_y,
self.weights_info,
self.index_info,
)
return _regrid_area_weighted_rectilinear_src_and_grid__perform(
cube, _regrid_info, mdtol=self._mdtol
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/analysis/cartography.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def wrap_lons(lons, base, period):
# It is important to use 64bit floating precision when changing a floats
# numbers range.
lons = lons.astype(np.float64)
return ((lons - base + period * 2) % period) + base
return ((lons - base) % period) + base


def unrotate_pole(rotated_lons, rotated_lats, pole_lon, pole_lat):
Expand Down
Loading

0 comments on commit f5a2841

Please sign in to comment.