Skip to content

test: migrate stats/incr/nanmpcorr to ULP-based assertions - #16203

Draft
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-stats-incr-nanmpcorr
Draft

kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-stats-incr-nanmpcorr

Conversation

@kgryte

@kgryte kgryte commented Oct 17, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

  • migrates the tests for stats/incr/nanmpcorr from relative tolerance assertions to ULP difference assertions using @stdlib/assert/is-almost-same-value.
  • replaces the delta/tol arithmetic (and the preceding actual === expected fast paths) with t.strictEqual( isAlmostSameValue( actual, expected, <ulp> ), true, 'returns expected value' );.
  • removes the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires.
  • pins the pseudorandom dataset seed (randu.seed → 123456) so that the measured ULP bounds are reproducible, as previously done for stats/incr/mapcorr and stats/incr/nanmapcorr.

Only test/test.js is modified; the package implementation is untouched.

ULP bounds

Each bound is the measured minimum: the suite fails if the bound is lowered by one.

Test Previous tolerance ULP bound
moving sample correlation coefficient, skipping NaN updates 5.0e5 * EPS * abs( expected ) 2457
moving sample correlation coefficient (known means), skipping NaN updates 5.0e5 * EPS * abs( expected ) 0
current sample correlation coefficient (unknown means), skipping NaN updates 2.0 * EPS * abs( expected ) 2
current sample correlation coefficient (known means), skipping NaN updates 2.0 * EPS * abs( expected ) 0

Bounds were found by starting high and tightening to the minimum passing integer over the full set of test data. The suite was run three times at the final bounds with identical results, and make eslint-tests TESTS_FILTER=".*/stats/incr/nanmpcorr/.*" reports no lint errors.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

The two bounds of 0 are exact matches, so isAlmostSameValue reduces to a SameValue comparison there, which is the minimum permitted value and matches the prior art in stats/incr/nanmapcorr.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

This pull request was authored by Claude Code running as an unattended scheduled task. Claude selected the package, studied the already-merged migrations for stats/incr/nanmapcorr and stats/incr/mcovariance to match the established idiom, applied the test changes, measured the minimum passing ULP bound at each assertion site, and wrote this description.


@stdlib-js/reviewers


Generated by Claude Code

Replace relative tolerance assertions with ULP difference assertions
using `@stdlib/assert/is-almost-same-value`. Each assertion uses the
minimum ULP bound which passes over the full set of test data.

In order for the measured ULP bounds to be reproducible, pin the
pseudorandom dataset seed, as previously done in the `stats/incr/mapcorr`
and `stats/incr/nanmapcorr` migrations.

Ref: #11352

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018DvFCXoqTpjUSaCsQzyyJB
@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Good First PR A pull request resolving a Good First Issue. labels Oct 17, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/incr/nanmpcorr $\\color{green}168/168$
$\\color{green}+100.00\\%$
$\\color{green}13/13$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}168/168$
$\\color{green}+100.00\\%$

The above coverage report was generated for the changes in this PR.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Good First PR A pull request resolving a Good First Issue. Statistics Issue or pull request related to statistical functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants