Skip to content

Tests: allow last-ulp libm differences in test_velocity_in_ITRF_to_GCRS2 (arm64) - #1147

Open
RegularJoe-CEO wants to merge 1 commit into
skyfielders:masterfrom
RegularJoe-CEO:fix-582-aarch64
Open

RegularJoe-CEO wants to merge 1 commit into
skyfielders:masterfrom
RegularJoe-CEO:fix-582-aarch64

Conversation

@RegularJoe-CEO

Copy link
Copy Markdown

The specific failure in #582 (test_frame_rotation_matrices using exact ==) no longer occurs on master; #844 replaced those checks with tolerances, and test_planetarylib.py passes on arm64 macOS today.

Running the full suite on current master (31a6ed7) on an Apple M1 (arm64, Python 3.9, NumPy 2.0.2) turns up one remaining arm64-only failure:

skyfield/tests/test_positions.py line 211 in test_velocity_in_ITRF_to_GCRS2
AssertionError: 1.8012730046149667e-11 not less than 1.8e-11

Same commit, same NumPy 2.0.2 and Python 3.9 on x86_64 Linux: 1.7352116665064965e-11 (passes, with only ~3.7% headroom).

Root cause: I dumped intermediate values on both machines as hex floats. t.tt and t.gast are bit-identical. The differences start in the transcendental functions: for 2000 sample inputs, np.sin/math.sin differ in the last ulp on 90 of them, np.cos on 92 and np.arctan on 41, while np.sqrt (correctly rounded under IEEE 754) matches on all 2000. That spreads into 4 elements of t.M and one component of the rotated position. The test then divides by the motion over one second, about 7.3e-5 of a unit vector, so a 1-ulp change in a position component (~1.1e-16) moves the relative error by ~1.5e-12. That is bigger than the margin the current 1.8e-11 limit leaves.

So the computation itself is fine, and the tolerance sits below the floating-point noise floor of the check. This PR raises it to 2.0e-11 and adds a comment explaining why. Results: all 584 tests pass on arm64 macOS and on x86_64 Linux (NumPy 2.0.2).

(Separately, and not touched here: with NumPy 2.5.4 on x86_64 there's an unrelated UFuncTypeError in timelib._utc at whole += whole2, an int64/float64 in-place add.)

This came up during LuxiEdge cross-platform determinism testing.

…yfielders#582)

test_velocity_in_ITRF_to_GCRS2 divides by a ~7.3e-5 finite-difference
motion, so 1-ulp differences in platform sin/cos/atan shift the relative
error by ~1.5e-12. On arm64 macOS it measured 1.801e-11 vs the 1.8e-11
limit (x86_64 glibc: 1.735e-11, same NumPy 2.0.2).
Copilot AI balanced review requested due to automatic review settings October 12, 2026 16:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The narrowly scoped tolerance increase accommodates the measured numerical variance while preserving a strict accuracy check.

0 open findings

What changed in this PR

Stabilizes a floating-point regression test across arm64 and x86_64 platforms without changing runtime behavior.

Changes:

  • Raises the relative-error tolerance from 1.8e-11 to 2.0e-11.
  • Documents platform-specific last-ULP variation.
File Description
skyfield/​tests/​test_positions.py Adjusts and explains the cross-platform tolerance.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants