Repository navigation
test: migrate stats/base/dists/halfnormal/entropy to ULP-based assertions - #14612
Merged
Merged
Conversation
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
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/halfnormal/entropyfrom relative tolerance testing to ULP difference testing, per [RFC]: Migratemath/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352.delta/tolcomparisons intest/test.jsandtest/test.native.jswitht.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' );, adding the@stdlib/assert/is-almost-same-valuerequire and dropping the now unused@stdlib/math/base/special/absand@stdlib/constants/float64/epsrequires.ULP bound:
2(bothtest/test.jsandtest/test.native.js), the measured minimum over the fixture set.The bound was determined empirically rather than assumed. Starting from a high bound and bisecting downward over
isAlmostSameValueacross the full SciPy fixture set (1000 values), the minimum admissible bound is exactly2. The distribution of ULP differences over the fixtures is:0ULP (bit-identical to the SciPy reference): 961 values1ULP: 36 values2ULP: 3 valuesThe largest ULP difference is therefore
2, attained atsigma = 3.3000421880500923(returned1.9197266052930475vs. expected1.919726605293048). Lowering the bound to1was confirmed to fail (3 failing assertions out of 1006 per suite), so the bound cannot be tightened further. The suite was then run twice at the final bound with identical results (1006/1006 passing per suite in each run), so the bound is not sensitive to run-to-run variation.The previous relative tolerance was
1.5 * EPS * abs( expected[ i ] ), which corresponds to roughly 1.5–3 ULP depending on where the expected value falls within its binade, so2sits within the prior accuracy budget rather than loosening it.To confirm that
2is also correct for the C implementation, the native addon was compiled locally andtest/test.native.jswas executed against the real addon rather than being skipped: it likewise passes all 1006 assertions at2ULP, twice, and bisecting the native results independently also yields2as the minimum, with the worst case at the same fixture index. This matches the sibling conversions in this family (beta/entropy,binomial/entropy,logistic/entropy), which likewise use a single bound across both suites.Only the two test files are modified; no implementation, fixture, or documentation changes are included.
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
Notes on local verification:
make install-node-modulesinitially failed in this environment because the local npm cache held a stale packument fores-object-atoms, causinges-object-atoms@^1.1.2to resolve as nonexistent. Clearing the npm cache resolved it; no repository files were involved.make lint-editorconfig-files(run via the pre-commit hook) could not execute because theeditorconfig-checkerbinary download is blocked in this environment. The changed files were instead checked manually for indentation (tabs), trailing whitespace, line endings (LF), and final newline, and match the surrounding files exactly.eslint --config etc/eslint/.eslintrc.tests.jsreports no problems for either file.make test TESTS_FILTER=".*/stats/base/dists/halfnormal/entropy/.*"passes (1006/1006).Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code running as an unattended scheduled task. It studied previously merged conversions under #11352 (including the
beta/entropyandbinomial/entropysiblings) to match the established idiom, applied the migration, measured the minimum ULP bound empirically against the fixtures for both the JavaScript and the locally compiled C implementation, and verified that the tests pass and that the files lint cleanly.@stdlib-js/reviewers
Generated by Claude Code