Skip to content

Commit 2352044

Browse files
committed
change topo coord test to explicit comparison of fixed values
1 parent 3e147f6 commit 2352044

File tree

1 file changed

+7
-25
lines changed

1 file changed

+7
-25
lines changed

astroquery/jplhorizons/tests/test_jplhorizons_remote.py

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
22

3-
import random
4-
53
from numpy.ma import is_masked
64
import numpy as np
75
import pytest
@@ -415,27 +413,11 @@ def test_geodetic_queries(self):
415413
black-box test for observer and vectors queries with geodetic
416414
coordinates. checks spatial sensibility.
417415
"""
418-
phobos = {
419-
'body': 401,
420-
'lon': random.randint(-150, -1),
421-
'lat': random.randint(-80, 80),
422-
'elevation': 0
423-
}
424-
deimos = {
425-
'body': 402,
426-
'lon': random.randint(-150, -1),
427-
'lat': random.randint(-80, 80),
428-
'elevation': 0
429-
}
430-
epochs = [random.randint(int(2.3e6), int(2.5e6))]
431-
deimos_phobos = jplhorizons.Horizons(
432-
phobos, location=deimos, epochs=epochs
433-
)
434-
phobos_deimos = jplhorizons.Horizons(
435-
deimos, location=phobos, epochs=epochs
436-
)
437-
pd_eph = phobos_deimos.ephemerides()
438-
dp_eph = deimos_phobos.ephemerides()
416+
phobos = {'body': 401, 'lon': -30, 'lat': -20, 'elevation': 0}
417+
deimos = {'body': 402, 'lon': -10, 'lat': -40, 'elevation': 0}
418+
deimos_phobos = jplhorizons.Horizons(phobos, location=deimos, epochs=2.4e6)
419+
phobos_deimos = jplhorizons.Horizons(deimos, location=phobos, epochs=2.4e6)
420+
pd_eph, dp_eph = phobos_deimos.ephemerides(), deimos_phobos.ephemerides()
439421
dp_xyz = spherical_to_cartesian(
440422
dp_eph['delta'], dp_eph['DEC'], dp_eph['RA']
441423
)
@@ -446,7 +428,7 @@ def test_geodetic_queries(self):
446428
eph_offset = (sum([off ** 2 for off in elementwise]) ** 0.5).to(u.km)
447429
# horizons can do better than this, but we'd have to go to a little
448430
# more trouble than is necessary for a software test...
449-
assert eph_offset < 10 * u.km
431+
assert np.isclose(eph_offset.value, 2.558895)
450432
# ...and vectors queries are really what you're meant to use for
451433
# this sort of thing.
452434
pd_vec, dp_vec = phobos_deimos.vectors(), deimos_phobos.vectors()
@@ -456,4 +438,4 @@ def test_geodetic_queries(self):
456438
+ dp_vec.as_array(names=('x', 'y', 'z')).view('f8')
457439
) ** 2
458440
)
459-
assert (vec_offset * u.au.to(u.km)) < 1
441+
assert np.isclose(vec_offset, 0)

0 commit comments

Comments
 (0)