Permalink
Browse files

Merge pull request #1832 from eteq/fix-1832

Coordinates equality comparison fails for array values
  • Loading branch information...
2 parents 10b3489 + 43fdf1a commit a4d082ead14979189dd95693d25dc21123d381dd @taldcroft taldcroft committed Feb 27, 2014
Showing with 19 additions and 3 deletions.
  1. +3 −0 CHANGES.rst
  2. +3 −3 astropy/coordinates/coordsystems.py
  3. +13 −0 astropy/coordinates/tests/test_arrays.py
View
@@ -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]
@@ -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
@@ -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

0 comments on commit a4d082e

Please sign in to comment.