Skip to content

Commit

Permalink
Merge pull request #2338 from greglucas/numpy-2.0
Browse files Browse the repository at this point in the history
Prepare for Numpy 2.0
  • Loading branch information
QuLogic committed Mar 10, 2024
2 parents 9201c7e + bd68ec5 commit bc7b373
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
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

0 comments on commit bc7b373

Please sign in to comment.