diff --git a/CHANGES.rst b/CHANGES.rst index 130d0e5e85f..a71803a88db 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -276,6 +276,9 @@ Bug Fixes - ``astropy.coordinates`` + - Fixed a bug where using ``==`` on two array coordinates wouldn't + work. [#1832] + - Fixed bug which caused `len()` not to work for coordinate objects and added a `shape` property to get appropriately array-like behavior. [#1761, #2014] diff --git a/astropy/coordinates/coordsystems.py b/astropy/coordinates/coordsystems.py index f1920831f19..d156c12fdb3 100644 --- a/astropy/coordinates/coordsystems.py +++ b/astropy/coordinates/coordsystems.py @@ -49,9 +49,9 @@ def __init__(self, *args, **kwargs): def __eq__(self, other): try: - return (self.latangle == other.latangle and - self.lonangle == other.lonangle and - self.distance == other.distance and + return (np.all(self.latangle == other.latangle) and + np.all(self.lonangle == other.lonangle) and + np.all(self.distance == other.distance) and self.equinox == other.equinox) except AttributeError: return False diff --git a/astropy/coordinates/tests/test_arrays.py b/astropy/coordinates/tests/test_arrays.py index b5624141fc9..f6527d63764 100644 --- a/astropy/coordinates/tests/test_arrays.py +++ b/astropy/coordinates/tests/test_arrays.py @@ -301,3 +301,16 @@ def test_array_len(): len(c) assert c.shape == tuple() + +def test_array_eq(): + from .. import ICRS + + c1 = ICRS([1, 2], [3, 4], unit=('deg', 'deg')) + c2 = ICRS([1, 2], [3, 5], unit=('deg', 'deg')) + c3 = ICRS([1, 3], [3, 4], unit=('deg', 'deg')) + c4 = ICRS([1, 2], [3, 4.2], unit=('deg', 'deg')) + + assert c1 == c1 + assert c1 != c2 + assert c1 != c3 + assert c1 != c4