Skip to content

test: migrate stats/incr/nanmpcorr2 to ULP-based assertions - #16123

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-stats-incr-nanmpcorr2
Oct 13, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-stats-incr-nanmpcorr2

Conversation

@kgryte

@kgryte kgryte commented Oct 13, 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/nanmpcorr2 from relative tolerance testing to ULP difference testing.
  • replaces the delta = abs( actual - expected ); tol = 5.0e5 * EPS * abs( expected ); comparisons with isAlmostSameValue( actual, expected, <ULP> ) assertions, adding the @stdlib/assert/is-almost-same-value require and dropping the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires.

Only test/test.js is modified; the package has no test/test.native.js.

ULP bounds

Each bound was found by measuring the maximum observed ULP difference over the full fixture set and was verified to be the minimum passing integer (decrementing any one of them fails the suite):

Test ULP
computes a moving squared sample Pearson product-moment correlation coefficient incrementally 4834
... incrementally (known means) 1857
returns the current squared sample correlation coefficient (unknown means) 2
returns the current squared sample correlation coefficient (unknown means, ignoring NaNs) 4

The larger bounds for the first two tests are consistent with the already migrated sibling package stats/incr/mpcorr2 (10425 and 3415), which exercises the same windowed accumulator over the same seeded datasets.

The test data is generated from a seeded PRNG, and the suite was run twice at the final bounds with identical results (2254 assertions, all passing).

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?

No.

Other

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

Linting the modified file reports the same set of findings before and after this change (all pre-existing and in untouched regions), so no new lint issues are introduced.

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, which performed the migration, measured the minimum ULP bounds empirically, and verified the test suite.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01H1a4NdkAZ2r2TeEPDzDx6Z


Generated by Claude Code

Replaces relative tolerance comparisons (`5.0e5 * EPS * abs( expected )`)
with `@stdlib/assert/is-almost-same-value` ULP difference assertions. Each
ULP bound was tightened to the measured minimum which still passes over the
full fixture set.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H1a4NdkAZ2r2TeEPDzDx6Z
@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 13, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

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!

@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/incr/nanmpcorr2 $\\color{green}170/170$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}170/170$
$\\color{green}+100.00\\%$

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

@kgryte kgryte added the Tests Pull requests specifically adding tests. label Oct 13, 2026
@kgryte
kgryte marked this pull request as ready for review October 13, 2026 22:03
@kgryte
kgryte requested a review from a team October 13, 2026 22:03
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Oct 13, 2026
@kgryte
kgryte merged commit 94f0584 into develop Oct 13, 2026
82 checks passed
@kgryte
kgryte deleted the kgryte/ulp-stats-incr-nanmpcorr2 branch October 13, 2026 22:04
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Oct 13, 2026
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. Tests Pull requests specifically adding tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants