diff --git a/.cirrus.yml b/.cirrus.yml index b3992de64a..efe7881548 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -32,7 +32,7 @@ env: # Increment the build number to force new nox cache upload. NOX_CACHE_BUILD: "0" # Increment the build number to force new pip cache upload. - PIP_CACHE_BUILD: "0" + PIP_CACHE_BUILD: "1" # Pip packages to be upgraded/installed. PIP_CACHE_PACKAGES: "nox pip pyyaml setuptools wheel" # Conda packages to be installed. diff --git a/docs/src/whatsnew/latest.rst b/docs/src/whatsnew/latest.rst index 33f2e7a699..44ad6c0fcd 100644 --- a/docs/src/whatsnew/latest.rst +++ b/docs/src/whatsnew/latest.rst @@ -202,10 +202,16 @@ 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:`3994`) + .. 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 diff --git a/lib/iris/analysis/cartography.py b/lib/iris/analysis/cartography.py index c699e7f8c4..373487af53 100644 --- a/lib/iris/analysis/cartography.py +++ b/lib/iris/analysis/cartography.py @@ -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): diff --git a/lib/iris/tests/unit/cube/test_Cube.py b/lib/iris/tests/unit/cube/test_Cube.py index b6856bd5f2..e54ae26e1d 100644 --- a/lib/iris/tests/unit/cube/test_Cube.py +++ b/lib/iris/tests/unit/cube/test_Cube.py @@ -1662,11 +1662,8 @@ def test_wrap_radians(self): cube = create_cube(0, 360) cube.coord("longitude").convert_units("radians") result = cube.intersection(longitude=(-1, 0.5)) - self.assertEqual( - result.coord("longitude").points[0], -0.99483767363676634 - ) - self.assertEqual( - result.coord("longitude").points[-1], 0.48869219055841207 + self.assertArrayAllClose( + result.coord("longitude").points, np.arange(-57, 29) * np.pi / 180 ) self.assertEqual(result.data[0, 0, 0], 303) self.assertEqual(result.data[0, 0, -1], 28)