Repository navigation
test: migrate stats/base/dists/weibull/mode to ULP-based assertions - #15513
Conversation
Migrate the tests for `stats/base/dists/weibull/mode` from relative tolerance assertions to ULP difference assertions using `@stdlib/assert/is-almost-same-value`. The ULP bound is `1` in both `test/test.js` and `test/test.native.js`, which is the measured minimum over the full 500-value Julia fixture set for both the JavaScript and C implementations. Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QMCnXVwjZRfgDEQ4Z47WVx
|
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/weibull/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:
1in bothtest/test.jsandtest/test.native.js.This is the measured minimum over the full 500-value Julia fixture set. Measuring the ULP distance between each computed value and its reference value directly:
lib/main.js)1src/main.c, vialib/native.js)11was confirmed to be the tightest passing bound: re-running both files at0fails with exactly one failing assertion in each (k = 15.188796105541709,lambda = 10.351582224226767, computed10.305270420548517vs. expected10.305270420548515), while1passes in full.A single-ULP discrepancy is expected here rather than a sign of an implementation problem. Both implementations evaluate the mode as
so a result depends on three separately rounded operations feeding a transcendental
powevaluation, and the reference values are computed in Julia. One ULP of disagreement on 1 of 500 fixtures is consistent with correctly rounded inputs to an inexactpow.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:
make test TESTS_FILTER=".*/stats/base/dists/weibull/mode/.*"→516passing,0failing.make eslint-tests TESTS_FILTER=".*/stats/base/dists/weibull/mode/.*"→ clean for both files.make install-node-addons NODE_ADDONS_PATTERN="mode") so thattest/test.native.jsactually executes rather than being skipped; it reports516passing assertions, confirming the fixture loop was not skipped.Note for reviewers: the
pre-commithook could not runlint-editorconfig-filesin this environment, as it attempts to download theeditorconfig-checkerbinary from GitHub releases and that request was blocked. The two changed files were instead verified manually against.editorconfig(LF line endings, UTF-8, tab indentation, no trailing whitespace, single final newline).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 (
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-ran the suite at0and at1to confirm minimality and determinism.@stdlib-js/reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01QMCnXVwjZRfgDEQ4Z47WVx
Generated by Claude Code