Repository navigation
test: migrate stats/base/dists/negative-binomial/variance to ULP-based assertions - #15954
Merged
Merged
Conversation
…sed assertions Migrate the native test suite from relative tolerance assertions to ULP difference assertions via `@stdlib/assert/is-almost-same-value`. Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TDyxNxcdwVVi7jiuRDFZCo
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/negative-binomial/variancefrom relative tolerance assertions to ULP difference assertions, per [RFC]: Migratemath/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352.Specifically, in
test/test.native.js:@stdlib/assert/is-almost-same-valueimport and removes the now-unused@stdlib/math/base/special/absand@stdlib/constants/float64/epsimports.delta/tolcomputation and they === expected[ i ]/ relative tolerance branch.t.strictEqual( ... )/t.ok( delta <= tol, ... )witht.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' );.Final ULP constant:
0.The bound was tightened empirically, rather than assumed. Starting from a high bound and lowering it, the measured maximum ULP difference across the full 200-case Julia fixture set is
0— the native (C) implementation reproduces every fixture value bit-for-bit, so0is both the measured minimum and the floor. The native test suite was run twice at the final bound to rule out FMA/architecture-dependent flakiness, passing 208/208 assertions both times with the native add-on compiled locally (so thetryRequireskip did not mask the assertions).Note that
test/test.jsis intentionally left unchanged: it already asserts exact equality viat.strictEqual( y, expected[ i ], ... )and contains no relative tolerance math, so there is nothing to migrate there.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.jswas left as-is because it performs exact comparisons rather than relative tolerance comparisons. If the preference is for both test files to use theisAlmostSameValueidiom consistently (as in, e.g.,stats/base/dists/beta/variance), I am happy to convert it as well.Other
test/test.native.js.make test TESTS_FILTER=".*/stats/base/dists/negative-binomial/variance/.*"passes, andeslintwithetc/eslint/.eslintrc.tests.jsreports no problems.lint-editorconfig-filespre-commit step could not execute in this environment because its checker binary could not be downloaded; EditorConfig conformance (tabs, LF line endings, final newline, no trailing whitespace introduced) was verified manually instead.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code as part of an automated, unattended pass over the packages tracked by #11352. The agent studied the migration idiom from already-converted packages in the same family (
stats/base/dists/beta/variance,stats/base/dists/negative-binomial/stdev), applied the mechanical transformation, compiled the native add-on, and measured the minimum viable ULP bound against the fixture set rather than guessing it.@stdlib-js/reviewers
Generated by Claude Code