Skip to content

test: migrate stats/incr/nangmean to ULP-based assertions - #15992

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

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

Conversation

@kgryte

@kgryte kgryte commented Oct 8, 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 test suite for stats/incr/nangmean from relative tolerance testing to ULP difference testing, replacing the computed delta/tol comparisons with @stdlib/assert/is-almost-same-value.

Two assertion sites were converted, and each ULP bound was tightened to the measured minimum which still passes over the full set of test cases:

Test case Final ULP bound
the accumulator function incrementally computes a geometric mean 2
if not provided an input value, the accumulator function returns the current geometric mean 1

How the minima were established:

  • The ULP difference was measured directly for every assertion in each test case via @stdlib/number/float64/base/ulp-difference. The largest observed difference in the incremental loop was 2 ULP (at the sixth accumulated value); the recall test differed by 1 ULP.
  • Lowering either bound by one (2 → 1 and 1 → 0, respectively) causes exactly one test failure, confirming that neither bound can be tightened further.
  • The suite was run twice at the final bounds, passing 18/18 both times, to confirm determinism (no FMA/architecture-dependent variation).

Notes:

  • The now-unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires, along with the corresponding delta and tol declarations, were removed.
  • Assertion messages were normalized to 'returns expected value', per the guidance in the tracking issue.
  • Only test/test.js is modified; there is no test/test.native.js for this package, and no source, documentation, or package.json changes were made.

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.

The ULP bounds here match the already-converted sibling package stats/incr/gmean, which uses 2 ULP for the equivalent incremental accumulation test.

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 running as an unattended scheduled task. It identified the candidate package, mirrored the conversion idiom from already-converted packages in the same family, measured the minimum ULP bounds empirically, and verified that the bounds cannot be tightened further.


@stdlib-js/reviewers


Generated by Claude Code

Replaces relative tolerance comparisons in the test suite with
`@stdlib/assert/is-almost-same-value` ULP difference assertions.

ULP bounds were tightened to the measured minimum which still passes
over the full set of test cases:

-   incremental geometric mean accumulation: 2 ULP
-   current geometric mean on recall: 1 ULP

Lowering either bound by one causes a test failure, and the suite was
run twice at the final bounds to confirm determinism.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HwRj94hUX3dG7FRc2TVZoc
@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 8, 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/nangmean $\\color{green}128/128$
$\\color{green}+100.00\\%$
$\\color{green}7/7$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}128/128$
$\\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