test: migrate stats/base/dists/halfnormal/stdev to ULP-based assertions - #14084
Conversation
…ions Replaces EPS-scaled relative tolerance comparisons with `@stdlib/assert/is-almost-same-value` in `test/test.js` and `test/test.native.js`. The ULP bound was tightened to the measured minimum of 1 ULP over the full Julia fixture set. Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X4ixBCT9ohYozkw8JZVWxV
|
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/halfnormal/stdevfrom EPS-scaled relative tolerance comparisons to ULP-based assertions using@stdlib/assert/is-almost-same-value, as described in [RFC]: Migratemath/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352.Both
test/test.jsandtest/test.native.jsare converted. In each, theif ( y === expected[i] ) { ... } else { delta/tol ... }block in the fixture loop is replaced by a singleand the now-unused
abs/EPSrequires anddelta/toldeclarations are removed. This mirrors the idiom already used in this family (e.g., #14069 forstats/base/dists/lognormal/variance).ULP bound:
1in bothtest/test.jsandtest/test.native.js.Measured minimum:
1. Over the full 50-value Julia fixture set (test/fixtures/julia/data.json), the per-fixture minimum ULP requirement was computed by searching upward from0; the maximum requirement across all fixtures was1(worst case:sigma = 2.577081059735365,y = 1.5534909422882428,expected = 1.553490942288243). AtN = 0, 6 of 50 fixtures fail, so1is tight and cannot be lowered further.test/test.jswas run twice at the final bound with identical results (55/55 assertions passing both times).The JavaScript implementation computes
sigma * sqrt( 1 - 2/pi )and the C implementation computessigma * SQRT1M2PIwithSQRT1M2PI = 0.6028102749890869. Those two scale constants are bit-identical, and each implementation performs a single multiplication, so the same1ULP bound applies to both and there is no FMA-contraction exposure.Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
The native addon could not be compiled in the environment used to prepare this change, so
test/test.native.jswas skipped locally (0 assertions run). The1ULP bound for the native tests was established analytically, as described above, rather than by execution. Please confirm the native tests pass in CI.Other
make install-node-modulesfailed in the environment used to prepare this change (the available npm registry snapshot has noes-object-atoms@^1.1.2, a transitive dependency), so the project's own lint tooling could not be run in full. Compensating checks that were run:test/test.jsexecuted with a locally installedtape: 55/55 assertions passing, twice.programmer_errors,best_practices,strict,variables,nodejs,style,es2015) plus the.eslintrc.tests.jsoverrides: clean. The customstdlib/*plugin rules could not be loaded (they pull in the remark toolchain), sorequire-order,vars-order,require-spaces,uppercase-required-constants, andno-empty-lines-between-requireswere verified by inspection against the rule definitions inetc/eslint/rules/stdlib.js.editorconfig-checkerdownloads its binary at runtime and could not fetch it.CI should be treated as the authoritative lint run. Only the two test files are changed; no source, docs, or
package.jsonchanges are included.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 previously merged conversions for the established idiom, applied the test changes, and measured the ULP bound empirically over the fixture set.
@stdlib-js/reviewers
Generated by Claude Code