Repository navigation
test: migrate stats/incr/mapcorr to ULP-based assertions - #16147
Conversation
Replace the relative tolerance assertions in the test suite with ULP difference assertions via `@stdlib/assert/is-almost-same-value`. In order for the fixture-based assertions to be deterministic, the simulated datasets now use a fixed PRNG seed, as is done in `stats/incr/mpcorr`. The measured minimum ULP bounds are `6716` (moving coefficient, unknown means), `1623` (moving coefficient, known means), `1` and `0` (accumulated coefficient, unknown and known means, respectively), and `1` (NaN propagation). Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ECS7suxhHt53frTb9zwh3T --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: skipped - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
|
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/incr/mapcorrfrom relative tolerance testing to ULP difference testing, replacing the computeddelta/tolcomparisons with@stdlib/assert/is-almost-same-value, following the idiom established in the already migratedstats/incr/mpcorr(the signed analog of this package) andstats/incr/mpcorr2.randu.seed) to a fixed seed (123456), which is required in order for a tightened ULP bound to be deterministic. This mirrorsstats/incr/mpcorr,stats/incr/mpcorr2, andstats/incr/nanmpcorr2, which all use the same fixed seed.Files changed (tests only):
test/test.jsTests which already performed exact comparisons (
t.strictEqualonnull,0, exactly representable values, andNaNchecks viaisnan) were left untouched.Measured ULP bounds
Each bound was tightened to the minimum integer that still passes over the full set of expected values in the corresponding test. The minima were measured programmatically (per-case minimum required ULP difference, maximized over the test's cases), and minimality was verified mechanically: decrementing any bound by one produces test failures.
NaN, the accumulated value isNaNfor at leastWinvocations (unknown means)Since
mapcorrreturns the absolute value of the coefficient computed bympcorr, the measured bounds for the two fixture-driven tests (6716and1623) are identical to the bounds already merged forstats/incr/mpcorr, which is a useful consistency check.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 change from
randu.seedto the fixed seed123456is strictly speaking beyond a mechanical tolerance-to-ULP substitution, but without it the datasets differ on every run and no tight ULP bound can be stated or relied upon. The already mergedstats/incr/mpcorr,stats/incr/mpcorr2, andstats/incr/nanmpcorr2made the same change as part of their migrations, so this follows precedent; please flag if a different seed is preferred.Other
make test TESTS_FILTER=".*/stats/incr/mapcorr/.*"is green (2422 assertions passing). The suite was run twice at the final ULP values to confirm determinism.make lint-javascript-tests TESTS_FILTER=".*/stats/incr/mapcorr/.*"is clean.test/test.native.js.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code. The ULP bounds were measured programmatically rather than guessed, and each bound was verified to be minimal by confirming that one less ULP fails.
@stdlib-js/reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01ECS7suxhHt53frTb9zwh3T
Generated by Claude Code