Skip to content

test: migrate stats/incr/mgmean to ULP-based assertions - #15334

Draft
Planeshifter wants to merge 1 commit into
developfrom
philipp/ulp-stats-incr-mgmean
Draft

Planeshifter wants to merge 1 commit into
developfrom
philipp/ulp-stats-incr-mgmean

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

  • Migrates stats/incr/mgmean's test/test.js from relative-tolerance (EPS-based) floating-point assertions to ULP-based assertions using @stdlib/assert/is-almost-same-value.
  • Removes the manual delta/tol computations (and the now-unneeded abs, EPSILON, and isnan requires) in favor of t.strictEqual( isAlmostSameValue( actual, expected, N ), true, 'returns expected value' ), mirroring the idiom used in previously merged conversions for other stats/incr/* packages (e.g., stats/incr/mse, stats/incr/me).
  • Uses the minimum required ULP value for each test block, determined empirically:
    • 'the accumulator function computes a moving geometric mean incrementally': 2 ULPs (measured max observed diff: 2 ULPs).
    • 'if not provided an input value, the accumulator function returns the current geometric mean': 0 ULPs (exact match).
    • 'if provided \NaN`, the accumulated value is `NaN` for at least `W` invocations': **1** ULP (measured max observed diff: 1 ULP; isAlmostSameValuealso correctly treatsNaN/NaNpairs as the same value, so the previous explicitisnan` branch could be folded into the same assertion).
  • Verified minimality: re-running with each bound lowered by 1 causes 3 assertions to fail, confirming the chosen values are the tightest that still pass deterministically. The suite was run twice at the final values with identical (fully passing) results.

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.

Verified via:

make test TESTS_FILTER=".*/stats/incr/mgmean/.*"

41/41 assertions pass. eslint run against the changed file reports no issues. Only test/test.js was changed; there is no test.native.js for this package.

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

This PR was written by Claude Code (an autonomous coding agent), which searched for a qualifying candidate package, studied prior merged conversions for the same idiom, performed the migration, and empirically determined the minimum ULP bounds described above by measuring actual ULP differences and confirming tightness/determinism through repeated test runs.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01Sk7xXaJe3eAEqJbbExepdj


Generated by Claude Code

Resolves a part of #11352

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Sk7xXaJe3eAEqJbbExepdj
@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 Sep 18, 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/mgmean $\\color{green}197/197$
$\\color{green}+100.00\\%$
$\\color{green}21/21$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}197/197$
$\\color{green}+100.00\\%$

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

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