Repository navigation
test: migrate stats/base/dists/invgamma/mode to ULP-based assertions - #15502
Conversation
Replace the computed relative-tolerance comparisons in `test/test.js` and `test/test.native.js` with ULP difference assertions using `@stdlib/assert/is-almost-same-value`. The measured maximum ULP difference over the full Julia fixture set is `0` for both the JavaScript and C implementations, so the tests now assert bitwise equality with the reference values. Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LRbc6joCcUqZmp2X4Va3wh
|
Hello! 👋 We've noticed that you've been opening a number of PRs addressing good first issues. Thank you for your interest and enthusiasm! Now that you've made a few contributions, we suggest no longer working on good first issues. Instead, we encourage you to prioritize cleaning up any PRs which have yet to be merged and then proceed to work on more involved tasks. Not only does this ensure that other new contributors can work on things and get ramped up on all things stdlib, it also ensures that you can spend your time on more challenging problems. 🚀 For ideas for future PRs, feel free to search the codebase for TODOs and FIXMEs and be sure to check out other open issues on the issue tracker. Cheers! |
Coverage Report
The above coverage report was generated for the changes in this PR. |
Resolves a part of #11352.
Description
This pull request:
stats/base/dists/invgamma/modefrom relative tolerance assertions to ULP difference assertions using@stdlib/assert/is-almost-same-value.Both
test/test.jsandtest/test.native.jspreviously compared against a computed relative tolerance:and now assert:
ULP constant:
0in bothtest/test.jsandtest/test.native.js.This is the measured minimum over the full 200-value Julia fixture set. Measuring the ULP distance between each computed value and its reference value directly:
lib/main.js)0src/main.c, vialib/native.js)00is the tightest representable bound, so no further tightening is possible.Exact agreement is expected here rather than fortuitous: both implementations evaluate the mode as a single IEEE-754 division,
so each result is correctly rounded and there is no accumulation, no transcendental evaluation, and no opportunity for FMA contraction to change the result. Note that at
maxULP === 0isAlmostSameValuefalls back to the SameValue algorithm, which is strictly stronger than the previousy === expected[ i ]fast path (it distinguishes-0from+0).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
Verification performed:
test/test.js→214passing,0failing.test/test.native.js→214passing,0failing. The native add-on was built locally (node-gyp configure buildin the package directory) so thattest/test.native.jsactually executes rather than being skipped; the assertion count confirms the tests were not skipped.etc/eslint/.eslintrc.tests.jsfor both files.One environment note for reviewers:
make install-node-modulescurrently fails in a clean container withETARGET: No matching version found for es-object-atoms@^1.1.2(requested byarray-includes@3.2.0, pulled in transitively viaeslint-plugin-import). The published versions ofes-object-atomstop out at1.1.1. This is unrelated to the changes in this PR, but it meant the test and lint runs above were performed against a locally assembled dependency set rather than viamake test/make lint.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 the already-merged conversions in this family (e.g.
stats/base/dists/invgamma/entropy,stats/base/dists/weibull/skewness,stats/base/dists/geometric/mean) to match the established idiom, then determined the ULP bound empirically by measuring the maximum ULP difference over the fixture set for both the JavaScript and C implementations and re-running the suite to confirm minimality and determinism.@stdlib-js/reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01LRbc6joCcUqZmp2X4Va3wh
Generated by Claude Code