Skip to content

test: migrate stats/incr/nanmapcorr to ULP-based assertions - #16163

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

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

Conversation

@kgryte

@kgryte kgryte commented Oct 15, 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/nanmapcorr from relative tolerance testing to ULP difference testing, replacing the computed delta/tol comparisons with @stdlib/assert/is-almost-same-value, following the idiom established in the already migrated stats/incr/mapcorr (the non-NaN analog of this package) and stats/incr/mpcorr.
  • switches the simulated datasets from the global PRNG seed (randu.seed) to a fixed seed (123456), which is required in order for a tightened ULP bound to be deterministic. This mirrors stats/incr/mapcorr, stats/incr/mpcorr, and stats/incr/mpcorr2, which all use the same fixed seed.

Files changed (tests only):

  • test/test.js

Tests which already performed exact comparisons (t.equal on null, 0, and NaN checks via isnan) were left untouched, as were the isnan( expected ) branches guarding the NaN-skipping behavior.

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 ULP difference, maximized over the test's cases), and minimality was verified mechanically: decrementing a non-zero bound by one produces test failures.

Test ULP
computes a moving sample absolute Pearson correlation coefficient incrementally and skip NaN updates 2457
computes a moving sample absolute Pearson correlation coefficient incrementally (known means) and skip NaN updates 0
if not provided an input value, returns the current coefficient (unknown means) and skips NaN updates 2
if not provided an input value, returns the current coefficient (known means) and skips NaN updates 0

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?

The change from randu.seed to the fixed seed 123456 is 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 merged stats/incr/mapcorr, stats/incr/mpcorr, and stats/incr/mpcorr2 made the same change as part of their migrations, so this follows precedent; please flag if a different seed is preferred.

Other

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

  • make test TESTS_FILTER=".*/stats/incr/nanmapcorr/.*" is green (2254 assertions passing). The suite was run twice at the final ULP values to confirm determinism.
  • make lint-javascript-tests TESTS_FILTER=".*/stats/incr/nanmapcorr/.*" is clean.
  • The package has no test/test.native.js.

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 PR was authored by Claude Code. The ULP bounds were measured programmatically rather than guessed, and each non-zero 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_01M1KYLesBsrREWPeaXVwgZ2


Generated by Claude Code

Migrate the tests for `stats/incr/nanmapcorr` from relative tolerance
testing to ULP difference testing using
`@stdlib/assert/is-almost-same-value`. Each ULP bound is tightened to the
minimum integer which still passes over the full set of test cases.

Additionally, switch the simulated datasets from the global PRNG seed
(`randu.seed`) to a fixed seed (`123456`), as is required in order for a
tightened ULP bound to be deterministic. This mirrors the already
migrated `stats/incr/mapcorr`, which is the non-NaN analog of this
package.

Ref: #11352

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/incr/nanmapcorr $\\color{green}155/155$
$\\color{green}+100.00\\%$
$\\color{green}11/11$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}155/155$
$\\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