Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1832 from eteq/fix-1832

Coordinates equality comparison fails for array values
  • Loading branch information...
commit a4d082ead14979189dd95693d25dc21123d381dd 2 parents 10b3489 + 43fdf1a
@taldcroft taldcroft authored
View
3  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]
View
6 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
View
13 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
Please sign in to comment.
Something went wrong with that request. Please try again.