Skip to content

test: migrate stats/incr/nanmmpe to ULP-based assertions - #16015

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-nanmmpe
Oct 11, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-nanmmpe

Conversation

@kgryte

@kgryte kgryte commented Oct 9, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

Specifically, in test/test.js:

  • adds the @stdlib/assert/is-almost-same-value import and removes the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps imports.
  • removes the delta/tol computation (and the corresponding variable declarations) in the test which checks that the accumulator function computes a moving mean percentage error incrementally.
  • replaces the t.equal( delta <= tol, ... ) tolerance branch with t.strictEqual( isAlmostSameValue( actual, expected[i], 1 ), true, 'returns expected value' );.

The final ULP constant is 1, which is the measured minimum. Starting from a loose bound of 64 and tightening over the full fixture set, 1 is the smallest integer which passes: at 0, three of the six fixture assertions fail. The suite was run twice at the final bound to confirm the result is deterministic (98 passing on both runs).

For reference, the non-NaN sibling package, stats/incr/mmpe, which shares the same fixture values, was previously migrated using the same 1 ULP bound.

No changes were made to the exact-equality assertions elsewhere in the file, as those compare exactly representable values and are correct as-is.

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.

Verification performed:

  • make test TESTS_FILTER=".*/stats/incr/nanmmpe/.*" → 98 passing, 0 failing (run twice at the final ULP bound).
  • Linting introduces no new findings: make lint-javascript-files reports an identical set of 13 pre-existing problems both before and after this change (these stem from the target applying the source ESLint overrides to a test file).
  • The only file changed is lib/node_modules/@stdlib/stats/incr/nanmmpe/test/test.js.

This package has no test/test.native.js, so only test/test.js required updating.

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. It studied the already-migrated sibling package stats/incr/mmpe to mirror the established project idiom, applied the migration, and determined the minimum passing ULP bound empirically by running the test suite across decreasing bounds.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_019LRi44byiqKb1zH1gx1krz


Generated by Claude Code

Replaces relative tolerance assertions with ULP difference assertions
using `@stdlib/assert/is-almost-same-value`. The ULP bound was tightened
to the measured minimum of 1 ULP.

Resolves a part of #11352.

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/incr/nanmmpe $\\color{green}149/149$
$\\color{green}+100.00\\%$
$\\color{green}8/8$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}149/149$
$\\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 11, 2026
@kgryte
kgryte marked this pull request as ready for review October 11, 2026 12:39
@kgryte
kgryte requested a review from a team October 11, 2026 12:39
@kgryte
kgryte merged commit 7704219 into develop Oct 11, 2026
66 checks passed
@kgryte
kgryte deleted the kgryte/ulp-nanmmpe branch October 11, 2026 12:39
@stdlib-bot stdlib-bot added Needs Review A pull request which needs code review. and removed Needs Review A pull request which needs code review. labels Oct 11, 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.

2 participants