Repository navigation
test(material): the direction table matches libm to within its last place, on any libm - #152
Merged
Merged
Conversation
…t place, on any libm The table is the bit contract shared verbatim with the C++ twin precisely so libm's sin/cos stay out of it, but the test asserted it equal to the host's math.sin/math.cos bit for bit. MSVC's CRT rounds sin(pi/4) the other way from glibc (0.7071067811865476 vs the table's ...475), so the test failed on Windows. It now checks each entry to within one ulp of 1.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test_direction_table_is_exact_and_matches_mathfailed on Windows, so this PR loosens the test to match the design. Nothing outside the test changes.Why it failed. The 16-direction table in
grl_snam/material.pyis the bit contract shared verbatim with the C++ twin, which is exactly why it is a table of constants: libm'ssin/cosstay out of the contract. The test nonetheless asserted each entry equal to the running host'smath.sin/math.cosbit for bit. MSVC's CRT roundssin(pi/4)the other way from glibc (0.7071067811865476 against the table's 0.7071067811865475), so the assertion fails there.The change. The test now checks each entry against
math.sin/math.costo within one ulp of 1.0. It still checks that the length is 1 to within 1e-15, and thatgate_directions(16)is the table itself.Tested:
tests/test_material_gate_sim.pypasses, 12 tests, on Windows (Python 3.11).