From 6e0201ecabc65544039790248f2eff3145088022 Mon Sep 17 00:00:00 2001 From: Brandon Rhodes Date: Fri, 24 Jul 2020 04:35:13 -0400 Subject: [PATCH] For #411, get all tests running under 32-bit Linux --- skyfield/tests/fixes.py | 3 +++ skyfield/tests/test_planetarylib.py | 16 +++++++++++++--- skyfield/tests/test_positions.py | 5 +++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/skyfield/tests/fixes.py b/skyfield/tests/fixes.py index ff6306e..e61e287 100644 --- a/skyfield/tests/fixes.py +++ b/skyfield/tests/fixes.py @@ -1,10 +1,13 @@ """Helpers for making Skyfield tests stable.""" import datetime as dt +import sys + from skyfield import earthlib import skyfield.api import skyfield.timelib +IS_32_BIT = (sys.maxsize == 0x7fffffff) _real_datetime_class = dt.datetime class datetime(dt.datetime): diff --git a/skyfield/tests/test_planetarylib.py b/skyfield/tests/test_planetarylib.py index 83877bd..5a5e429 100644 --- a/skyfield/tests/test_planetarylib.py +++ b/skyfield/tests/test_planetarylib.py @@ -2,6 +2,7 @@ import numpy as np from skyfield.api import PlanetaryConstants, T0, load from skyfield.constants import AU_KM, AU_M from skyfield.positionlib import ICRF +from .fixes import IS_32_BIT def test_frame_rotation_matrices(): # To produce the following matrices: @@ -47,7 +48,10 @@ def test_frame_rotation_matrices(): R2, Rv = frame.rotation_and_rate_at(ts.tdb_jd(tdb)) assert (R == R2).all() - assert (Rv == desired_rate).all() # Boom. + if IS_32_BIT: + assert abs(Rv - desired_rate).max() < 3e-26 + else: + assert (Rv == desired_rate).all() # Boom. # Second, a moment when the angle W is more than 2500 radians. @@ -93,11 +97,17 @@ def test_frame_rotation_matrices(): frame = pc.build_frame_named('MOON_ME_DE421') R = frame.rotation_at(ts.tdb_jd(tdb)) delta = abs(R - desired_rotation) - assert (R == desired_rotation).all() + if IS_32_BIT: + assert abs(R - desired_rotation).max() < 2e-16 + else: + assert (R == desired_rotation).all() R2, Rv = frame.rotation_and_rate_at(ts.tdb_jd(tdb)) assert (R == R2).all() - assert (Rv == desired_rate).all() + if IS_32_BIT: + assert abs(Rv - desired_rate).max() < 2e-23 + else: + assert (Rv == desired_rate).all() def test_rotating_vector_into_frame(): et_seconds = 259056665.1855896 diff --git a/skyfield/tests/test_positions.py b/skyfield/tests/test_positions.py index c96ff99..2bc797f 100644 --- a/skyfield/tests/test_positions.py +++ b/skyfield/tests/test_positions.py @@ -5,7 +5,7 @@ from skyfield.earthlib import earth_rotation_angle from skyfield.functions import length_of, mxv, rot_z from skyfield.positionlib import ICRF, ITRF_to_GCRS2, _GIGAPARSEC_AU from skyfield.starlib import Star -from .fixes import low_precision_ERA +from .fixes import IS_32_BIT, low_precision_ERA def test_subtraction(): p0 = ICRF((10,20,30), (40,50,60)) @@ -126,7 +126,8 @@ def test_velocity_in_ITRF_to_GCRS2(): relative_error = (length_of(actual_motion - predicted_motion) / length_of(actual_motion)) - assert relative_error < 2e-12 + acceptable_error = 4e-12 if IS_32_BIT else 2e-12 + assert relative_error < acceptable_error # Test that the CIRS coordinate of the TIO is consistent with the Earth Rotation Angle # This is mostly an internal consistency check