For #411, get all tests running under 32-bit Linux

This commit is contained in:
Brandon Rhodes 2020-07-24 04:35:13 -04:00
parent b5d5e37342
commit 6e0201ecab
3 changed files with 19 additions and 5 deletions

View File

@ -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):

View File

@ -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

View File

@ -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