Repository navigation
test: migrate stats/base/dists/f/mode to ULP-based assertions - #14147
Merged
Merged
Conversation
Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017bXA4hmb4tnGe18yLCcToS
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/f/modefrom relative tolerance testing to ULP difference testing, replacing thedelta/tolcomparisons intest/test.jsandtest/test.native.jswithisAlmostSameValue.@stdlib/assert/is-almost-same-valueimport and removes the now unused@stdlib/constants/float64/epsand@stdlib/math/base/special/absimports.Final ULP constant:
0, in both test files.The ULP bound was measured rather than guessed: for every fixture value, the minimum ULP difference which admits the computed result was determined directly (searching upward from
0), and the maximum over the full fixture set was taken.data.json1.0*EPSBoth the JavaScript and C implementations reproduce every Julia fixture value exactly, so the measured minimum is
0ULP — the tightest bound expressible. This is expected here: both implementations evaluate the identical expression( ( d1-2.0 ) / d1 ) * ( d2 / ( d2+2.0 ) ), which is two divisions and a multiplication with no opportunity for FMA contraction.test/test.native.jswas verified against a locally compiled add-on (make install-node-addons NODE_ADDONS_PATTERN='stats/base/dists/f/mode') so that it did not skip; the0ULP bound is therefore measured for the C implementation as well, not merely inherited from the JavaScript results. Each suite was run twice at the final bound to confirm determinism (no FMA/architecture variation); all assertions pass on every run (test.js: 116,test.native.js: 116).Only the two test files are changed; the implementation and fixtures are untouched.
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
Opened as a draft pending maintainer review of the
0ULP bound. A bound of0requires bit-for-bit agreement with the fixtures; there is existing precedent in the repo (stats/base/dists/pareto-type1/quantile,stats/base/dists/weibull/logcdf,stats/base/dists/uniform/entropy, andmath/base/special/covercosall use0for fixture groups which match exactly), and the results here are deterministic IEEE-754 in both implementations. If maintainers would prefer a1ULP margin intest/test.native.jsas a hedge against compiler/architecture variation in the C build, that is a one-character change.Two environment notes, neither affecting the diff:
editorconfig-checkerstage of the local pre-commit hook could not run, because it downloads its binary from a GitHub release which was not reachable from this environment. EditorConfig conformance was instead verified manually for the changed files (LF line endings, UTF-8, tab indentation, no trailing whitespace, final newline present). Linting passes cleanly with the repository's test configuration (make lint-javascript-files ESLINT_CONF=./etc/eslint/.eslintrc.tests.js FILES=...).make install-node-modulesinitially failed in this environment because a transitive dependency requested a registry version which was not resolvable here (es-object-atoms@^1.1.2; the registry as seen from this environment publishes at most1.1.1). A subsequent install attempt resolved successfully and produced a working toolchain. Flagging it in case CI hits the same intermittent resolution failure.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written by Claude Code running as an unattended scheduled task: it selected the package, studied prior conversions in the repo to match the established idiom, applied the test migration, measured the minimum ULP bound empirically, and verified tests and linting locally.
@stdlib-js/reviewers
Generated by Claude Code