Skip to content

Commit 80a1477

Browse files
committed
Update test_eloc_attributes to test correctly and also be explained
The != comparison was leading to a false positive, but only on some systems (i.e., astropy#3496, where it was failing because of lower precision)
1 parent 1a2d67e commit 80a1477

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

‎astropy/coordinates/tests/test_frames.py‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -552,20 +552,29 @@ def test_eloc_attributes():
552552

553553
el1 = AltAz(location=el).location
554554
assert isinstance(el1, EarthLocation)
555+
# these should match *exactly* because the EarthLocation
555556
assert el1.latitude == el.latitude
556557
assert el1.longitude == el.longitude
557558
assert el1.height == el.height
558559

559560
el2 = AltAz(location=it).location
560561
assert isinstance(el2, EarthLocation)
561-
assert el2.latitude != it.spherical.lat
562-
assert el2.longitude != it.spherical.lon
562+
# these should *not* match because giving something in Spherical ITRS is
563+
# *not* the same as giving it as an EarthLocation: EarthLocation is on an
564+
# elliptical geoid. So the longitude should match (because flattening is
565+
# only along the z-axis), but latitude should not. Also, height is relative
566+
# to the *surface* in EarthLocation, but the ITRS distance is relative to
567+
# the center of the Earth
568+
assert not np.allclose(el2.latitude, it.spherical.lat)
569+
assert np.allclose(el2.longitude, it.spherical.lon)
563570
assert el2.height < -6000*u.km
564571

565-
el3 = AltAz(location=gc).location #this one implicitly does transform_to
572+
el3 = AltAz(location=gc).location
573+
# GCRS inputs implicitly get transformed to ITRS and then onto
574+
# EarthLocation's elliptical geoid. So both lat and lon shouldn't match
566575
assert isinstance(el3, EarthLocation)
567-
assert el3.latitude != gc.dec
568-
assert el3.longitude != gc.ra
576+
assert not np.allclose(el3.latitude, gc.dec)
577+
assert not np.allclose(el3.longitude, gc.ra)
569578
assert np.abs(el3.height) < 500*u.km
570579

571580

0 commit comments

Comments
 (0)