Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for Numpy 2.0 #2338

Merged
merged 2 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions lib/cartopy/mpl/gridliner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 180 if (longitude > 0 and lon_wrapped == -180) else lon_wrapped
if longitude > 0:
hemisphere = 'E'
elif longitude < 0:
Expand Down
2 changes: 1 addition & 1 deletion lib/cartopy/tests/crs/test_oblique_mercator.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def test_equality(oblique_variants):
"reverse_coord", [False, True], ids=["xy_order", "yx_order"]
)
def test_nan(oblique_mercator, plate_carree, reverse_coord):
coord = (0.0, np.NaN)
coord = (0.0, np.nan)
if reverse_coord:
coord = tuple(reversed(coord))
res = oblique_mercator.transform_point(*coord, src_crs=plate_carree)
Expand Down