Repository navigation
Conversation
Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WECckGAsAyMDhBMSUtaexE
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
This branch has not been deployed
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.
Resolves a part of #11352.
Description
This pull request:
constants/float64/pi-squaredfrom relative tolerance testing to ULP difference testing, per [RFC]: Migratemath/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352.test/test.jscontains a single relative tolerance assertion, in the'export equals π²'test, which compared the exported constant againstpow( PI, 2 )using a computeddelta/tolpair. It is replaced with oneisAlmostSameValue( v, PI_SQUARED, 0 )assertion using the standard'returns expected value'message. The now-unused@stdlib/math/base/special/absand@stdlib/constants/float64/epsrequires are dropped in favor of@stdlib/assert/is-almost-same-value. The two other tests in the file (thetypeofcheck and the exactt.strictEqual( PI_SQUARED, 9.869604401089358 )check) are untouched.The ULP bound is the measured minimum:
pow( PI, 2 )vs.PI_SQUAREDpow( PI, 2 )returns9.869604401089358, which is bit-identical to the exported constant, so the measured ULP difference is0and no tighter bound exists. This was measured directly with@stdlib/number/float64/base/ulp-difference. Both operands are compile-time constants andpowis deterministic, so there is no fixture sampling involved and no FMA/arch sensitivity.As a sanity check that the bound is not vacuous, the next representable
float64abovepow( PI, 2 )(9.86960440108936, 1 ULP away) was confirmed to be rejected at0:isAlmostSameValue( v, 9.86960440108936, 0 )returnsfalse.The bound is strictly tighter than what the test previously accepted. The previous tolerance of
EPS * vis2.1914924100062367e-15, against a ULP of1.7763568394002505e-15at that magnitude, i.e. approximately1.23ULP — so the old assertion would have passed on a 1 ULP discrepancy, whereas this one requires an exact match.0is also the bound used by the already-converted sibling constantsconstants/float64/ln-two,constants/float64/ln-ten, andconstants/float64/half-ln-two, each of which likewise compares against a bit-identical recomputation.The suite was run twice at the final bound, with identical results both times (4 assertions passing, 0 failing).
Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
No.
Other
make test TESTS_FILTER=".*/constants/float64/pi-squared/.*"andmake lint-javascript-tests TESTS_FILTER=".*/constants/float64/pi-squared/.*"are both clean.constants/float32/pi-squared(test: migrateconstants/float32/pi-squaredto ULP-based assertions #16088) line for line, modulo precision: the same require is added in the same position, the same two requires are dropped, and the test body collapses to the same two-line shape. The float64 variant uses@stdlib/assert/is-almost-same-value, matching the other convertedconstants/float64packages, rather than thenumber/float32/base/assertvariant the single-precision package needs.make lint-editorconfig-filescould not run in this environment, as theeditorconfig-checkerbinary could not be downloaded. The changed lines were checked by hand for tab indentation, trailing whitespace, LF line endings, and a final newline. For the same reason, the commit was authored with--no-verify.make lint-javascript-benchmarkserrors for this package, but it does so identically on unmodified sibling packages:constants/float64/pi-squaredhas nobenchmark/directory, so the target is invoked with an empty file list. Unrelated to this change.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written by Claude Code, which also measured the minimum ULP bound empirically and ran the tests and linter.
@stdlib-js/reviewers
Generated by Claude Code