test: migrate stats/base/dists/bernoulli/skewness to ULP-based assertions - #14391
Conversation
…rtions Ref: #11352 Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01U1Fsx8FyCM2U9HpHWjDvY1
|
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/bernoulli/skewnessfrom relative tolerance testing (delta = abs( y - expected[i] ),tol = 1.0 * EPS * abs( expected[i] ),t.ok( delta <= tol, ... )) to ULP difference testing using@stdlib/assert/is-almost-same-value.test/test.jsandtest/test.native.js, which mirror one another.@stdlib/math/base/special/absand@stdlib/constants/float64/epsimports from both test files (EPSis not used anywhere else in these files).The ULP bounds were tightened to the measured minimum which passes over the full fixture set, for both the JavaScript and the C implementations:
fixtures/julia/data.json0Notes on how the bound was determined:
64, the bound was lowered stepwise (64,16,4,2,1,0), with the full suite run at each step; all 1000 fixture values are bit-for-bit exact against the Julia reference values, for both implementations, so0is both the measured maximum and the tightest possible bound. The measurement was also performed directly, by computing the ULP difference for each fixture value via@stdlib/number/float64/base/assert/is-almost-same-value.( 1 - 2p ) / sqrt( p * ( 1 - p ) ), and both the JavaScript and C implementations evaluate exactly that expression in the same order.2 * pis exact,sqrtis correctly rounded under IEEE 754, and the division is a single correctly rounded operation, so there is no room for the two implementations to diverge, and no opportunity for FMA contraction to change a result.y === expected[i]fast path was taken for every fixture value and the tolerance branch was never exercised.test.jsandtest.native.jsuse identical bounds.test/test.native.jswas exercised against the actual C implementation rather than skipped. Both test files were run twice at the final bound, with identical results (1009 assertions each, all passing, per run).Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
Given that every fixture value is bit-for-bit exact, a bound of
0is equivalent to a strict equality check. Reviewers may prefer plaint.strictEqual( y, expected[ i ], ... )here instead;isAlmostSameValue( ..., 0 )was chosen for consistency with the other converted packages, which already use a0bound in many places.Other
etc/eslint/.eslintrc.tests.js(verified against a deliberately introduced violation to confirm the configuration was actually applied).make install-node-modulescould not complete in this environment: a transitive dependency requireses-object-atoms@^1.1.2, which is newer than themin-release-age = 90threshold configured in the repository.npmrc, so the registry resolution fails. Rather than weakening that setting, the required test tooling (tape, ESLint 8.57 and the repository's remark/ESLint plugins,node-gyp) was installed separately, and the tests and linter were run directly against the package. Nothing outsidenode_moduleswas affected.editorconfigpre-commit hook could not run in this environment, as it downloads its binary from a GitHub repository that this session cannot reach. The two files were instead checked manually against.editorconfig(LF endings, tab indentation, final newline, UTF-8); the diff introduces no new violations.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. The test migration follows the idiom established by previously merged conversions, and the ULP bound was measured empirically against both the JavaScript and compiled C implementations rather than guessed.
@stdlib-js/reviewers
Generated by Claude Code