From b69e16936454b82b7c3e829f04d2d742ff8a6738 Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Mon, 4 Mar 2024 17:34:32 -0700 Subject: [PATCH] MNT: Remove unnecessary array copy=False semantics for numpy 2.0 --- lib/cartopy/mpl/gridliner.py | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/lib/cartopy/mpl/gridliner.py b/lib/cartopy/mpl/gridliner.py index 41ce669d0..61f4eab03 100644 --- a/lib/cartopy/mpl/gridliner.py +++ b/lib/cartopy/mpl/gridliner.py @@ -53,21 +53,11 @@ ) -def _fix_lons(lons): - """ - Fix the given longitudes into the range ``[-180, 180]``. - - """ - lons = np.array(lons, copy=False, ndmin=1) - fixed_lons = ((lons + 180) % 360) - 180 - # Make the positive 180s positive again. - fixed_lons[(fixed_lons == -180) & (lons > 0)] *= -1 - return fixed_lons - - def _lon_hemisphere(longitude): """Return the hemisphere (E, W or '' for 0) for the given longitude.""" - longitude = _fix_lons(longitude) + # Wrap the longitude to the range -180 to 180, keeping positive 180s + lon_wrapped = ((longitude + 180) % 360) - 180 + longitude = longitude if (longitude > 0 and lon_wrapped == -180) else lon_wrapped if longitude > 0: hemisphere = 'E' elif longitude < 0: