Skip to content

Commit

Permalink
Merge pull request #1832 from eteq/fix-1832
Browse files Browse the repository at this point in the history
Coordinates equality comparison fails for array values
  • Loading branch information
taldcroft committed Feb 27, 2014
2 parents 10b3489 + 43fdf1a commit a4d082e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions astropy/coordinates/coordsystems.py
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions astropy/coordinates/tests/test_arrays.py
Expand Up @@ -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.