Conversation
Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ecr737FjApcfYpgXawH2cM
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/strided/sstdevycfrom relative tolerance testing to ULP difference testing, replacing the computeddelta/tolcomparisons with@stdlib/number/float32/base/assert/is-almost-same-value.Concretely, in each of
test/test.sstdevyc.js,test/test.sstdevyc.native.js,test/test.ndarray.js, andtest/test.ndarray.native.js, the followingis replaced by
along with adding the
@stdlib/number/float32/base/assert/is-almost-same-valuerequire and dropping the now-unused@stdlib/math/base/special/absand@stdlib/constants/float32/epsrequires and thedelta/toldeclarations.As this package operates on single-precision floating-point numbers, the tests use the single-precision assertion utility (
isAlmostSameValuef), matching the convention already established by the sibling packagesstats/strided/sstdev,stats/strided/sstdevpn, andstats/strided/sstdevwd, whose test files are otherwise nearly identical to this package's.ULP bounds
Each of the four files contains two tolerance-based assertions. The measured minimum differs between them, so each assertion carries its own bound rather than a single uniform value:
the function calculates the population standard deviation of a strided array11the function calculates the sample standard deviation of a strided array00The bounds are identical across all four files.
The bounds were tightened empirically rather than guessed. Starting from a high value (
64) and lowering it, the population assertion fails at0and passes at1, while the sample assertion is bit-exact and so passes at0:So
1is the tightest possible non-exact bound for the population case, and the sample case requires no tolerance at all.The native add-on was compiled locally, so the bounds in the
*.native.jsfiles are measured rather than mirrored: the JavaScript and C implementations return the same value for both cases, and the ULP distances above hold for each. The full test suite was run twice at the final values to confirm the result is stable (no FMA/arch-dependent variation); both runs report the same77passing assertions and0failures.Note that the prior state of this package applied a uniform
1.0 * EPSrelative tolerance to both assertions, which is why the sample case was not previously distinguishable as exact. If reviewers would prefer a uniform1in both positions for consistency with the siblingsstdev/sstdevpn/sstdevwdpackages — trading the tighter bound for robustness against a future bit-level change insvarianceyc— that is a one-character change and I am happy to make it.Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
Only the one noted above: whether the exact (
0ULP) bound on the sample standard deviation assertion is preferred over a uniform1, given that the issue asks for the minimum required ULP value.Other
Only the four test files are modified; no source, documentation, benchmark, or fixture files are touched.
test/test.jscontains no tolerance-based assertions and is left unchanged.Verification performed:
make test TESTS_FILTER=".*/stats/strided/sstdevyc/.*"—77passing,0failing, with the native add-on built so thattest.sstdevyc.native.jsandtest.ndarray.native.jsactually execute rather than skip. Run twice, with identical results.0, which fails as expected.make lint-javascript-tests TESTS_FILTER=".*/stats/strided/sstdevyc/.*"— clean,0problems across all files..editorconfig, as theeditorconfig-checkerbinary could not be downloaded in the sandbox used to author this change.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 task. It studied the migration idiom from previously merged conversions in the same family, applied the mechanical substitution to the four test files, and determined the ULP bounds by measuring the actual ULP distance for both the JavaScript and C implementations and confirming that a lower bound fails while the chosen bound passes, then re-running the suite to confirm the result is deterministic.
@stdlib-js/reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01Ecr737FjApcfYpgXawH2cM
Generated by Claude Code