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

Fix infinite coordinates failing to be equal #441

Merged
merged 1 commit into from
Jul 6, 2022
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
5 changes: 4 additions & 1 deletion pyresample/spherical.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ class SCoordinate(object):
"""

def __init__(self, lon, lat):
self.lon = float(_unwrap_radians(lon))
if np.isfinite(lon):
self.lon = float(_unwrap_radians(lon))
else:
self.lon = float(lon)
self.lat = lat

def cross2cart(self, point):
Expand Down
6 changes: 6 additions & 0 deletions pyresample/test/test_spherical.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ def test_equality_at_antimeridian(self):
point_end = SCoordinate(np.pi, 0)
assert point_start == point_end

def test_equality_of_infinites(self):
"""Test that infinite coordinates are equal."""
coord1 = SCoordinate(np.inf, np.inf)
coord2 = SCoordinate(np.inf, np.inf)
assert coord1 == coord2


class TestCCoordinate(unittest.TestCase):
"""Test SCoordinates."""
Expand Down