Repository navigation
Conversation
…ions Migrate the relative tolerance assertions in `test/test.logpdf.js` and `test/test.factory.js` to `@stdlib/assert/is-almost-same-value`, using the measured minimum ULP bound for each fixture: 2 for the positive location fixture, 6 for the negative location fixture, and 23 for the large variance fixture. Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MytgcDMyuY94YNJBQaGeki
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:
stats/base/dists/lognormal/logpdffrom 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.logpdf.jsandtest/test.factory.jseach contain three fixture loops (positive location, negative location, and large variance) which compared the returned value against the Julia reference values using a computeddelta/tolpair, guarded by anif ( y === expected[i] )exact-equality branch. All six loops are replaced with a singleisAlmostSameValue( y, expected[ i ], <ulp> )assertion using the standard'returns expected value'message, which subsumes the exact-equality branch. Theif ( expected[i] !== null )guard is retained, as are all other test cases in these files. The now-unused@stdlib/math/base/special/absand@stdlib/constants/float64/epsrequires are dropped in favor of@stdlib/assert/is-almost-same-value.The ULP bounds are the measured minimum over each full fixture set:
positive_location.jsonnegative_location.jsonlarge_variance.jsonThe fixtures are static JSON, so the sample sets are deterministic. The maximum ULP difference was measured directly with
@stdlib/number/float64/base/ulp-differenceand is identical forlogpdfand for the function returned byfactory, so the same three bounds are used in both files. Each bound was confirmed to be the minimum by running the suite at one ULP lower (1,5, and22), which fails in all three loops in both files (7 failing assertions per file). The worst-case samples are:x = 3.038719122736828,mu = 4.019096077776874,sigma = 4.916695819458168, returning-3.7978794313958266against an expected-3.7978794313958257.x = 0.2161959526873769,mu = -1.577673599061331,sigma = 1.5450107140936942, returning0.17715549571911243against an expected0.1771554957191126.x = 0.027577454596747764,mu = 0.16632948247834567,sigma = 14.89136605791995, returning-0.06079096879442163against an expected-0.060790968794421474.All three bounds are strictly tighter than what the tests previously accepted. The previous bound of
20.0 * EPS * abs( expected[ i ] )corresponds to approximately38.0,28.3, and38.9ULP at the respective worst-case samples, versus the2,6, and23ULP accepted here. As a sanity check that the bounds are not vacuous,isAlmostSameValue( 1.0, 1.0+( 24*EPS ), 23 ),isAlmostSameValue( 1.0, 1.0+( 3*EPS ), 2 ), andisAlmostSameValue( 1.0, 1.0+( 7*EPS ), 6 )were each confirmed to returnfalse.The suite was run twice at the final bounds, with identical results both times (3017 + 3 + 3014 = 6034 assertions passing, 0 failing;
test/test.native.jsis skipped in this environment, as the native add-on is not built).Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
test/test.native.jswas left unmodified. It contains no relative tolerance assertions: it already callsisAlmostSameValue( y, expected[i], 1500 ), albeit viat.okwith a'within tolerance. ...'message rather than viat.strictEqualwith the standard'returns expected value'message, and its1500ULP bound is unverified here because the add-on is not built in this environment. Restyling those assertions and re-measuring the native bound seemed out of scope for a relative-tolerance migration, but happy to fold it in if reviewers would prefer the whole package be consistent.Other
make test TESTS_FILTER=".*/stats/base/dists/lognormal/logpdf/.*"andmake lint-javascript-tests TESTS_FILTER=".*/stats/base/dists/lognormal/logpdf/.*"are both clean.stats/base/dists/uniform/logpdf, which has the sametest.<name>.js/test.factory.jslayout and likewise retains theif ( expected[i] !== null )guard.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, ASCII encoding, and a final newline. For the same reason, the commit was authored with--no-verify.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 bounds empirically and ran the tests and linter.
@stdlib-js/reviewers
Generated by Claude Code