test: migrate stats/base/dists/cosine/stdev to ULP-based assertions - #14211
Conversation
Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VM8TrUPLiKK9AWMBWRbsXu
|
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. |
Description
This pull request:
stats/base/dists/cosine/stdevfrom relative tolerance (EPS-based) comparisons to ULP-based assertions, per [RFC]: Migratemath/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352.Specifically, in both
test/test.jsandtest/test.native.js, the fixture loop'sdelta/tolcomputation is replaced withadding a
@stdlib/assert/is-almost-same-valuerequire and dropping the now-unused@stdlib/math/base/special/absand@stdlib/constants/float64/epsrequires.Final ULP constant:
1(bothtest.jsandtest.native.js).The bound was tightened empirically rather than assumed. Starting from
64, the minimum passing integer over the full fixture set (100 non-nullcases) is1:N = 0: 36 of 110 assertions fail;N = 1: 110/110 pass.The maximum observed ULP difference across the fixtures is exactly 1 ULP.
test.jswas run twice at the finalNwith identical results. The native test is skipped locally (the addon is not built in this environment), but the same bound is safe by construction:src/main.candlib/main.jsboth computes * 0.36151205519132795using the identical constant. A single IEEE-754 double multiplication is correctly rounded and admits no FMA contraction, so the native result is bit-identical to the JavaScript result and the measured 1 ULP bound carries over.Only the two test files are modified; no implementation, fixture, or documentation changes.
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
The full project toolchain could not be installed in the authoring environment:
make install-node-modulesfails withETARGET: No matching version found for es-object-atoms@^1.1.2(the registry reachable from that environment publishes only up to1.1.1), somake initand the projecteslintconfiguration could not be run. As a workaround,tapewas installed in an isolated scratch directory to execute the package's test suite, and the changed files were linted against core rules (no-unused-vars,no-undef,no-trailing-spaces,no-mixed-spaces-and-tabs,one-var,vars-on-top,semi,eqeqeq,no-irregular-whitespace), which report clean. The diff otherwise mirrors the idiom of previously merged conversions (e.g. #14163, #14155) verbatim. Leaving this as a draft so CI can confirm the full lint and native builds.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 surveyed prior merged conversions to match the established idiom, applied the test changes, and determined the minimum ULP bound empirically by bisecting the constant against the full fixture set.
@stdlib-js/reviewers
Generated by Claude Code