From 80a887877fed618b20755ec420d8fc46390f1a59 Mon Sep 17 00:00:00 2001 From: Bill Little Date: Wed, 30 Sep 2020 15:16:26 +0100 Subject: [PATCH 1/2] Deprecate iris.util.as_compatible_shape --- docs/iris/src/whatsnew/latest.rst | 4 ++++ lib/iris/util.py | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/docs/iris/src/whatsnew/latest.rst b/docs/iris/src/whatsnew/latest.rst index 312ccf9f48..13e84e1619 100644 --- a/docs/iris/src/whatsnew/latest.rst +++ b/docs/iris/src/whatsnew/latest.rst @@ -165,6 +165,10 @@ This document explains the changes made to Iris for this release ``int``. The deprecated attributes ``flag1``, ``flag2`` etc. have been removed from it. (:pull:`3461`) +* `@bjlittle`_ deprecated :func:`~iris.util.as_compatible_shape` in preference + for :class:`~iris.common.resolve.Resolve`. The :func:`~iris.util.as_compatible_shape` + function will be removed in a future release of Iris. + 🔗 Dependencies =============== diff --git a/lib/iris/util.py b/lib/iris/util.py index 2e69ca6f97..0403e4d0f2 100644 --- a/lib/iris/util.py +++ b/lib/iris/util.py @@ -24,6 +24,7 @@ import numpy.ma as ma import iris +from iris._deprecation import warn_deprecated import iris.coords import iris.exceptions import iris.cube @@ -1222,6 +1223,8 @@ def as_compatible_shape(src_cube, target_cube): .. note:: This function will load and copy the data payload of `src_cube`. + .. deprecated:: 3.0.0 + Args: * src_cube: @@ -1236,6 +1239,12 @@ def as_compatible_shape(src_cube, target_cube): suitably reshaped to fit. """ + wmsg = ( + "iris.util.as_compatible_shape has been deprecated and will be " + "removed, please use iris.common.resolve.Resolve instead." + ) + warn_deprecated(wmsg) + dim_mapping = {} for coord in target_cube.aux_coords + target_cube.dim_coords: dims = target_cube.coord_dims(coord) From 49bb4be839477ad2061219e0a7ce5848c1503664 Mon Sep 17 00:00:00 2001 From: Bill Little Date: Wed, 30 Sep 2020 16:06:33 +0100 Subject: [PATCH 2/2] review actions --- docs/iris/src/whatsnew/latest.rst | 5 +++-- lib/iris/util.py | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/iris/src/whatsnew/latest.rst b/docs/iris/src/whatsnew/latest.rst index 13e84e1619..3d8ff3285a 100644 --- a/docs/iris/src/whatsnew/latest.rst +++ b/docs/iris/src/whatsnew/latest.rst @@ -166,8 +166,9 @@ This document explains the changes made to Iris for this release removed from it. (:pull:`3461`) * `@bjlittle`_ deprecated :func:`~iris.util.as_compatible_shape` in preference - for :class:`~iris.common.resolve.Resolve`. The :func:`~iris.util.as_compatible_shape` - function will be removed in a future release of Iris. + for :class:`~iris.common.resolve.Resolve` e.g., ``Resolve(src, tgt)(tgt.core_data())``. + The :func:`~iris.util.as_compatible_shape` function will be removed in a future + release of Iris. (:pull:`3892`) 🔗 Dependencies diff --git a/lib/iris/util.py b/lib/iris/util.py index 0403e4d0f2..d2fda82c0f 100644 --- a/lib/iris/util.py +++ b/lib/iris/util.py @@ -1225,6 +1225,10 @@ def as_compatible_shape(src_cube, target_cube): .. deprecated:: 3.0.0 + Instead use :class:`~iris.common.resolve.Resolve`. For example, rather + than calling ``as_compatible_shape(src_cube, target_cube)`` replace + with ``Resolve(src_cube, target_cube)(target_cube.core_data())``. + Args: * src_cube: