Skip to content

Commit 4abaa8f

Browse files
bjlittletkknightznichollstrexfeathersjonseddon
authored
Mergeback v3.0.x release feature branch (#4276)
* Add release highlights and pin rc version (#3898) * Add release highlights and pin rc version * review actions * reorder release highlights (#3899) Tweak release highlights * Add whatsnew announcement (#3900) * Fix spelling (#3903) * Fix unit label handling (#3902) * Add failing test of plotting * Implement fix to pass test * Update idiff to ignore irrelevant hyphens in path * Update imagerepo (following docs) * Update after review by @trexfeathers * Add whatsnew entries * Move whatsnew entries into correct file * Release Docs Improvements (#3895) * Minor phrasing change in 'Release candidate'. * Before release deprecations. * Whatsnew highlights section. * Relax setup.py setup requirements (#3909) * Updated CF saver version in User Guide and docstring (#3925) * Updated CF saver version in User Guide and docstring * Remove references to CF version of the loader in docstrings * Added whatsnew * Pin cftime<1.3.0 * Migrate to cirrus-ci (#3928) * migrate from travis-ci to cirrus-ci * added whatsnew entries * ignore url for doc link check (#3929) * whatsnew for coord default units (#3924) * Cube._summary_coord_extra: efficiency and bugfix (#3922) * Add Documentation Title Case Capitalization (#3940) * Use Title Case Capitalisation for Documentation * add whatsnew enter * CI requirements drop pip packages (#3939) * requirements pip to conda * use pip install over develop * default PY_VER to python versions * update links (#3942) * update links * added s to http * Add support for 1-d weights in collapse. (#3943) * Remove warning for convert_units on lazy data (#3951) * drop stickler references in docs (#3953) * drop stickler references in docs * remove sticker from common links * update docs for travis-ci to cirrus-ci (#3954) * update docs for travis-ci to cirrus-ci * add 'travis-ci' reference locally to whatsnew * update whatsnew comment * docs for nox (#3955) * docs for nox * add titles, notices and additional detail * review actions * Resolve test coverage (#3947) * test coverage for __init__ and __call__ * test coverage for metadata resolve and coverage * partial test coverage for metadata mapping * python 3.6 workaround for deepcopy of mock.sentinel * test coverage for Resolve._free_mapping * test coverage for Resolve convenience methods * add test stub for Resolve._metadata_mapping * fix Test__tgt_cube_position * test coverage for shape * test coverage for _as_compatible_cubes * test coverage for Resolve._metadata_mapping * test coverage for Resolve._prepare_common_dim_payload * test coverage for Resolve._prepare_common_aux_payload * test coverage for Resolve._prepare_points_and_bounds * test coverage for Resolve._create_prepared_item * test coverage for Resolve._prepare_local_payload_dim * test coverage for Resolve._prepare_local_payload_aux * test coverage for Resolve._prepare_local_payload_scalar + docs URL skip * test coverage for Resolve._prepare_local_payload * test coverage for Resolve._metadata_prepare * added docs URL linkcheck skip * test coverage for Resolve._prepare_factory_payload * test coverage for Resolve._get_prepared_item * review actions * test coverage for Resolve.cube * pin v3.0.0 version and whatnew date (#3956) * update github ci checks image (#3957) * Promote unknown units to dimensionless in aux factories (#3965) * promote unknown to dimensionless units in aux factories * patch aux factories to promote unknown to dimensionless units for formula terms * add whatnew PR for entry * Release branch prepare for v3.0.2 (#4044) * update intersphinx mapping and matplotlib urls (#4003) * update intersphinx mapping and matplotlib urls * use matplotlib intersphinx where possible * review actions * review actions * cirrus-ci compute credits (#4007) * cirrus-ci conditional tasks (#4019) * cirrus-ci conditional tasks * use bc for bash arithmetic * revert back to sed * use expr * reword * minor documentation changes * review actions * prepare v3.0.2 release * Fix test_incompatible_dimensions test (#3977) * test_incompatible_dimensions used a ragged array for the test, which has been deprecated in numpy, and now fails if dtype is anything other than object. This test appears to be checking that the addition of a [2x4] masked array to a [2x3] masked cube should raise a ValueError. This commit fixes the creation of `data3` object to be a [2x4] non-ragged array. * Added entry to what's new * Added name to core developer list :) * Update latest.rst Fixed space in PR macro call * update whatsnew v3.0.2 Co-authored-by: James Penn <[email protected]> * um_stash_source attribute improved handling (#4035) * Modified pyke rule * Tests added * Black and whatsnew * Include PR number * Remove latest.rst * Add what's new * Support for py38 and Cartopy 0.19 (#4130) * mpl 3.4.1 updates (#4087) * replace most recent hashes (#4112) * Corrected plot_anomaly_log_colouring for new Matplotlib linscale rules. (#4115) * Cartopy 0.19 updates (#4128) * Use assertArrayAllClose for sqrt test (#4118) * using AllClose for sqrt test * Omitting the checksum from test cml * use ArrayAllClose (rebase reset it?) * Iris py38 (#3976) * support for py38 * update CI and noxfile * enforce alphabetical xml element attribute order * full tests for py38 + fix docs-tests * add whatsnew entry * update doc-strings + review actions * Alternate xml handling routine (#29) * all xml tests pass for nox tests-3.8 * restored docstrings * move sort_xml_attrs * make sort_xml_attrs a classmethod * update sort_xml_attr doc-string Co-authored-by: Bill Little <[email protected]> * add jamesp to whatsnew + minor tweak Co-authored-by: James Penn <[email protected]> * reinstate black and nox links * Linkcheck update (#4104) * Updated links * Added login remark * Removed extra space * change to kick cirrus * kick cirrus * test verbose on cirrus * Removed test settings. Co-authored-by: Bill Little <[email protected]> Co-authored-by: Martin Yeo <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: James Penn <[email protected]> Co-authored-by: James Penn <[email protected]> Co-authored-by: tkknight <[email protected]> * Intersection bounds fix (replacement PR) (#4059) * fix intersection out of bounds point * fix intersection out of bounds point take 2 * add referencing comment * bootstrap ci for 3.0.x (#4154) * add cirrus-ci docker support * wip * wip * wip * wip * wip * add pip * revert docker * fix add_weekday (#32) * fix add_weekday * fix black link * fix link Co-authored-by: Ruth Comer <[email protected]> * Tweak to speed up dask wrapping of netcdf variables (#4135) * Use 'meta' in da.from_array to stop it sampling netcdf variables, which is quite slow. * Fix PR number. * Fix test. * Review changes. * Update docs/iris/src/whatsnew/3.0.2.rst Co-authored-by: lbdreyer <[email protected]> * Fb fix cube coord arithmetic (#4159) * fix coord with cube arithmetic * add coord arithmetic test coverage * add a whatsnew entry * Pp daskfix (#4141) * Remove workaround when dask-wrapping PP data, obsoleted by #4135. * Remove old slice testing * Add whats new * move whitespace? * missing line Co-authored-by: lbdreyer <[email protected]> * add release date to v3.0.2 whatsnew (#4160) * update readme logo img src and href (#4006) (#4216) * In cube.intersection, find split cells using a tolerant equality check (#4220) * In cube.intersection, find split cells using a tolerant equality check * remove unused var * Add bounds check to tests; add what's new * Fix whats new; update version number * Update 3.0.3.rst Update release date in `3.0.3.rst` * Wide cubestr fix 3v0vx v2 (#4233) * Widen cube printout for long ancil or cell-measure names. * Adjust result for fixed cube-units printout. * Added whatsnew. * Include newest whatsnew in index. * Review: fix whatsnew structure. * Fix initial sections display. * Fix some typos in the cube maths docs (#4248) * (More of) Wide cubestr fix 3v0vx v2 (#4238) * Fix whatsnew for #4233. * Move 'empty slicings' whatsnew entry to 3.0.2 section. * unpin cftime (#4222) * Test wrangling vs v3.0.x (#4249) * test changes * add awol init * rename system test cases * fix PartialDateTime tests * fix typo * add whatsnew * Fix mergeback PR #4035 * Fix mergeback PR #4035 tests * Update mergeback nox conda-lock files Co-authored-by: tkknight <[email protected]> Co-authored-by: Zeb Nicholls <[email protected]> Co-authored-by: Martin Yeo <[email protected]> Co-authored-by: Jon Seddon <[email protected]> Co-authored-by: Ruth Comer <[email protected]> Co-authored-by: Patrick Peglar <[email protected]> Co-authored-by: James Penn <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: James Penn <[email protected]> Co-authored-by: Ruth Comer <[email protected]> Co-authored-by: lbdreyer <[email protected]> Co-authored-by: lbdreyer <[email protected]>
1 parent 06d5242 commit 4abaa8f

39 files changed

Lines changed: 2335 additions & 403 deletions

docs/src/userguide/cube_maths.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Let's extend this example slightly, by taking a slice from the middle
157157
air_temperature / (K) (longitude: 49; time: 240)
158158

159159
Compared to our original time-series, the *air_temp_T_slice* cube has one
160-
less dimension *and* it's shape if different. However, this doesn't prevent
160+
less dimension *and* its shape is different. However, this doesn't prevent
161161
us from performing cube arithmetic with it, thanks to the extended cube
162162
broadcasting behaviour::
163163

@@ -237,7 +237,7 @@ by a cube with unit ``'1'`` will preserve units, so the cube ``temperature``
237237
will be given the same units as are in ``pot_temperature``. It should be
238238
noted that some combinations of units, particularly those involving power
239239
operations, will not result in a valid unit and will cause the calculation
240-
to fail. For example, a cube ``a`` had units ``'m'`` then ``a ** 0.5``
240+
to fail. For example, if a cube ``a`` had units ``'m'`` then ``a ** 0.5``
241241
would result in an error since the square root of a meter has no meaningful
242242
unit (if ``a`` had units ``'m2'`` then ``a ** 0.5`` would result in a cube
243243
with units ``'m'``).

docs/src/whatsnew/3.0.1.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ This document explains the changes made to Iris for this release
2424
factory, and the associated derived coordinate will be missing. (:pull:`3965`)
2525

2626

27-
.. dropdown:: :opticon:`report` Release Highlights
27+
.. dropdown:: :opticon:`report` v3.0.0 Release Highlights
2828
:container: + shadow
2929
:title: text-primary text-center font-weight-bold
3030
:body: bg-light
3131
:animate: fade-in
32-
:open:
3332

3433
The highlights for this major release of Iris include:
3534

docs/src/whatsnew/3.0.2.rst

Lines changed: 571 additions & 0 deletions
Large diffs are not rendered by default.

docs/src/whatsnew/3.0.3.rst

Lines changed: 586 additions & 0 deletions
Large diffs are not rendered by default.

docs/src/whatsnew/3.0.4.rst

Lines changed: 620 additions & 0 deletions
Large diffs are not rendered by default.

docs/src/whatsnew/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ Iris versions.
1111
:maxdepth: 1
1212

1313
latest.rst
14+
3.0.4.rst
15+
3.0.3.rst
16+
3.0.2.rst
1417
3.0.1.rst
1518
3.0.rst
1619
2.4.rst

lib/iris/_lazy_data.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ def as_lazy_data(data, chunks=None, asarray=False):
191191
if isinstance(data, ma.core.MaskedConstant):
192192
data = ma.masked_array(data.data, mask=data.mask)
193193
if not is_lazy_data(data):
194-
data = da.from_array(data, chunks=chunks, asarray=asarray)
194+
data = da.from_array(
195+
data, chunks=chunks, asarray=asarray, meta=np.ndarray
196+
)
195197
return data
196198

197199

lib/iris/coords.py

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -403,28 +403,15 @@ def __binary_operator__(self, other, mode_constant):
403403
# Note: this method includes bounds handling code, but it only runs
404404
# within Coord type instances, as only these allow bounds to be set.
405405

406-
if isinstance(other, _DimensionalMetadata) or not isinstance(
407-
other, (int, float, np.number)
408-
):
409-
410-
def typename(obj):
411-
if isinstance(obj, Coord):
412-
result = "Coord"
413-
else:
414-
# We don't really expect this, but do something anyway.
415-
result = self.__class__.__name__
416-
return result
417-
418-
emsg = "{selftype} {operator} {othertype}".format(
419-
selftype=typename(self),
420-
operator=self._MODE_SYMBOL[mode_constant],
421-
othertype=typename(other),
406+
if isinstance(other, _DimensionalMetadata):
407+
emsg = (
408+
f"{self.__class__.__name__} "
409+
f"{self._MODE_SYMBOL[mode_constant]} "
410+
f"{other.__class__.__name__}"
422411
)
423412
raise iris.exceptions.NotYetImplementedError(emsg)
424413

425-
else:
426-
# 'Other' is an array type : adjust points, and bounds if any.
427-
result = NotImplemented
414+
if isinstance(other, (int, float, np.number)):
428415

429416
def op(values):
430417
if mode_constant == self._MODE_ADD:
@@ -441,8 +428,14 @@ def op(values):
441428

442429
new_values = op(self._values_dm.core_data())
443430
result = self.copy(new_values)
431+
444432
if self.has_bounds():
445433
result.bounds = op(self._bounds_dm.core_data())
434+
else:
435+
# must return NotImplemented to ensure invocation of any
436+
# associated reflected operator on the "other" operand
437+
# see https://docs.python.org/3/reference/datamodel.html#emulating-numeric-types
438+
result = NotImplemented
446439

447440
return result
448441

@@ -461,8 +454,7 @@ def __div__(self, other):
461454
def __truediv__(self, other):
462455
return self.__binary_operator__(other, self._MODE_DIV)
463456

464-
def __radd__(self, other):
465-
return self + other
457+
__radd__ = __add__
466458

467459
def __rsub__(self, other):
468460
return (-self) + other
@@ -473,8 +465,7 @@ def __rdiv__(self, other):
473465
def __rtruediv__(self, other):
474466
return self.__binary_operator__(other, self._MODE_RDIV)
475467

476-
def __rmul__(self, other):
477-
return self * other
468+
__rmul__ = __mul__
478469

479470
def __neg__(self):
480471
values = -self._core_values()

lib/iris/cube.py

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3193,24 +3193,26 @@ def _intersect_modulus(
31933193
# and call the new bounds = the new points + the difference.
31943194
pre_wrap_delta = np.diff(coord.bounds[inside_indices])
31953195
post_wrap_delta = np.diff(bounds[inside_indices])
3196-
close_enough = np.allclose(pre_wrap_delta, post_wrap_delta)
3197-
if not close_enough:
3198-
split_cell_indices, _ = np.where(
3199-
pre_wrap_delta != post_wrap_delta
3200-
)
3201-
3202-
# Recalculate the extended minimum.
3196+
split_cell_indices, _ = np.where(
3197+
~np.isclose(pre_wrap_delta, post_wrap_delta)
3198+
)
3199+
if split_cell_indices.size:
32033200
indices = inside_indices[split_cell_indices]
32043201
cells = bounds[indices]
3205-
cells_delta = np.diff(coord.bounds[indices])
3206-
3207-
# Watch out for ascending/descending bounds
3208-
if cells_delta[0, 0] > 0:
3209-
cells[:, 0] = cells[:, 1] - cells_delta[:, 0]
3210-
minimum = np.min(cells[:, 0])
3211-
else:
3212-
cells[:, 1] = cells[:, 0] + cells_delta[:, 0]
3213-
minimum = np.min(cells[:, 1])
3202+
if maximum % modulus not in cells:
3203+
# Recalculate the extended minimum only if the output bounds
3204+
# do not span the requested (minimum, maximum) range. If
3205+
# they do span that range, this adjustment would give unexpected
3206+
# results (see #3391).
3207+
cells_delta = np.diff(coord.bounds[indices])
3208+
3209+
# Watch out for ascending/descending bounds.
3210+
if cells_delta[0, 0] > 0:
3211+
cells[:, 0] = cells[:, 1] - cells_delta[:, 0]
3212+
minimum = np.min(cells[:, 0])
3213+
else:
3214+
cells[:, 1] = cells[:, 0] + cells_delta[:, 0]
3215+
minimum = np.min(cells[:, 1])
32143216

32153217
points = wrap_lons(coord.points, minimum, modulus)
32163218

@@ -3764,37 +3766,49 @@ def __ne__(self, other):
37643766
def __hash__(self):
37653767
return hash(id(self))
37663768

3767-
def __add__(self, other):
3768-
return iris.analysis.maths.add(self, other)
3769+
__add__ = iris.analysis.maths.add
37693770

37703771
def __iadd__(self, other):
37713772
return iris.analysis.maths.add(self, other, in_place=True)
37723773

37733774
__radd__ = __add__
37743775

3775-
def __sub__(self, other):
3776-
return iris.analysis.maths.subtract(self, other)
3776+
__sub__ = iris.analysis.maths.subtract
37773777

37783778
def __isub__(self, other):
37793779
return iris.analysis.maths.subtract(self, other, in_place=True)
37803780

3781+
def __rsub__(self, other):
3782+
return (-self) + other
3783+
37813784
__mul__ = iris.analysis.maths.multiply
3782-
__rmul__ = iris.analysis.maths.multiply
37833785

37843786
def __imul__(self, other):
37853787
return iris.analysis.maths.multiply(self, other, in_place=True)
37863788

3789+
__rmul__ = __mul__
3790+
37873791
__div__ = iris.analysis.maths.divide
37883792

37893793
def __idiv__(self, other):
37903794
return iris.analysis.maths.divide(self, other, in_place=True)
37913795

3792-
__truediv__ = iris.analysis.maths.divide
3796+
def __rdiv__(self, other):
3797+
data = 1 / self.core_data()
3798+
reciprocal = self.copy(data=data)
3799+
return iris.analysis.maths.multiply(reciprocal, other)
37933800

3794-
def __itruediv__(self, other):
3795-
return iris.analysis.maths.divide(self, other, in_place=True)
3801+
__truediv__ = __div__
3802+
3803+
__itruediv__ = __idiv__
3804+
3805+
__rtruediv__ = __rdiv__
37963806

37973807
__pow__ = iris.analysis.maths.exponentiate
3808+
3809+
def __neg__(self):
3810+
return self.copy(data=-self.core_data())
3811+
37983812
# END OPERATOR OVERLOADS
37993813

38003814
def collapsed(self, coords, aggregator, **kwargs):

lib/iris/fileformats/_nc_load_rules/actions.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@
4343
from functools import wraps
4444
import warnings
4545

46+
from iris.config import get_logger
4647
import iris.fileformats.cf
4748
import iris.fileformats.pp as pp
4849

4950
from . import helpers as hh
5051

52+
# Configure the logger.
53+
logger = get_logger(__name__, fmt="[%(funcName)s]")
54+
5155

5256
def _default_rulenamesfunc(func_name):
5357
# A simple default function to deduce the rules-name from an action-name.
@@ -385,13 +389,23 @@ def action_ukmo_stash(engine):
385389
attr_name = "ukmo__um_stash_source"
386390
attr_value = getattr(var, attr_name, None)
387391
if attr_value is None:
388-
attr_altname = "um_stash_source" # legacy form
389-
attr_value = getattr(var, attr_altname, None)
392+
attr_name = "um_stash_source" # legacy form
393+
attr_value = getattr(var, attr_name, None)
390394
if attr_value is None:
391395
rule_name += "(NOT-TRIGGERED)"
392396
else:
393397
# No helper routine : just do it
394-
engine.cube.attributes["STASH"] = pp.STASH.from_msi(attr_value)
398+
try:
399+
stash_code = pp.STASH.from_msi(attr_value)
400+
except (TypeError, ValueError):
401+
engine.cube.attributes[attr_name] = attr_value
402+
msg = (
403+
"Unable to set attribute STASH as not a valid MSI "
404+
f'string "mXXsXXiXXX", got "{attr_value}"'
405+
)
406+
logger.debug(msg)
407+
else:
408+
engine.cube.attributes["STASH"] = stash_code
395409

396410
return rule_name
397411

0 commit comments

Comments
 (0)