Repository navigation
Conversation
Migrates the `stats/incr/mpcorr` test suite from relative tolerance
testing to ULP difference testing.
- Adds the `@stdlib/assert/is-almost-same-value` import and removes
the now-unused `@stdlib/math/base/special/abs` and
`@stdlib/constants/float64/eps` imports.
- Replaces the `delta`/`tol` computations and their
`t.strictEqual( delta < tol, ... )` assertions with
`t.strictEqual( isAlmostSameValue( actual, expected, N ), true,
'returns expected value' )`, using the measured minimum `N`.
- Pins the PRNG seed used to generate the sample datasets, as
previously done in `stats/incr/mpcorr2` and
`stats/incr/nanmpcorr2`, so that the ULP bounds are deterministic.
Ref: #11352
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018GzPhMP8iKCvtg52SimALy
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves a part of #11352.
Description
This pull request:
stats/incr/mpcorrtest suite from relative tolerance testing to ULP difference testing, per [RFC]: Migratemath/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352.Specifically, this pull request:
@stdlib/assert/is-almost-same-valueimport and removes the now-unused@stdlib/math/base/special/absand@stdlib/constants/float64/epsimports.delta/tolcomputations (and the correspondingvar delta;/var tol;declarations) from the six fixture loops which used them.if ( actual === expected ) { ... } else { ... delta/tol ... }branches with a singlet.strictEqual( isAlmostSameValue( actual, expected, N ), true, 'returns expected value' );assertion.Only
test/test.jsis modified; the package has notest/test.native.js. No other test cases were touched, and existing exact comparisons (t.strictEqual/t.notEqual/isnanchecks) were left as-is.The conversion mirrors, line for line, the already-merged
stats/incr/mpcorr2migration. That package's test file is structurally identical to this one apart from squaring the correlation coefficient, so it serves as direct prior art for every change here.ULP bounds
Each fixture loop was tightened independently to the measured minimum:
acc()returns current coefficient, unknown meansacc()returns current coefficient, known meansNaNhandling, unknown means (both data orderings)The bounds were tightened agentically, starting high and lowering. Each one is confirmed minimal: lowering
6716to6715,1623to1622, or any of the1s to0causes the suite to fail on exactly the affected assertions. The0bound is already the floor (isAlmostSameValuewithmaxULP === 0reduces toisSameValue, and all values in that loop compare exactly equal).The large bounds in the first two cases reflect the catastrophic cancellation inherent to incrementally accumulating a moving correlation coefficient over datasets spanning ten orders of magnitude; they are of the same order as the
10425/3415bounds accepted for the corresponding loops instats/incr/mpcorr2, and are substantially tighter than the relative tolerance they replace (5.0e5 * EPS, i.e. roughly2.3e6ULP).Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
Flagging one change for explicit review: pinning the PRNG seed (see "Other" below). It is strictly necessary for the ULP bounds to be meaningful, and it follows the precedent set by
stats/incr/mpcorr2andstats/incr/nanmpcorr2, but it is the one change in this PR which is not a pure assertion rewrite. Happy to revisit if a different seed or a different approach is preferred.Other
datasets( N, M, randu.seed ).randu.seedis seeded non-deterministically per process, so the sample datasets — and therefore the observed ULP differences — varied from run to run, which makes a minimum ULP bound impossible to establish or to keep stable in CI. Both calls are nowdatasets( N, M, 123456 ), matching the already-mergedstats/incr/mpcorr2andstats/incr/nanmpcorr2test files, which pin the same seed value for the same reason. All remaining uses ofranduin the file (the window-size-1test cases) are untouched.make test TESTS_FILTER=".*/stats/incr/mpcorr/.*"passes 2422/2422. The suite was run twice at the final bounds with identical results, and the per-loop maximum ULP differences were separately measured across three additional runs, all identical — confirming determinism (no FMA/arch-dependent variation in this environment).make eslint-tests TESTS_FILTER=".*/stats/incr/mpcorr/.*"passes cleanly.lint-editorconfig-filestarget could not be run in this environment because it downloads theeditorconfig-checkerbinary from a GitHub repository that was not reachable from the sandbox (HTTP 403). The file was instead verified programmatically against.editorconfig: LF line endings, valid UTF-8, tab indentation (no space-indented lines), no trailing whitespace, and a 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 selected the package at random from the remaining unconverted candidates, studied the already-merged
stats/incr/mpcorr2migration as prior art, performed the test conversion, and determined the minimum ULP bounds empirically by instrumenting the suite to record the maximum ULP difference observed in each fixture loop and then confirming that each bound minus one fails.@stdlib-js/reviewers
Generated by Claude Code