Skip to content

test: migrate stats/incr/nanmrange to ULP-based assertions - #16260

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

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

Conversation

@kgryte

@kgryte kgryte commented Oct 20, 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/nanmrange from tolerance-based assertions to ULP-based assertions, replacing the hard-coded absolute tolerance in test/test.js

    t.ok( abs(v - expected[i]) < 0.01, 'returns expected value for window '+i );

    with

    t.strictEqual( isAlmostSameValue( v, expected[ i ], 1 ), true, 'returns expected value' );
  • adds the @stdlib/assert/is-almost-same-value require and drops the now unused @stdlib/math/base/special/abs require.

Final ULP constant: 1. This is the measured minimum. The single inexact assertion compares the accumulator output for the window [3.14, 5.0] (i.e., 5.0 - 3.14, which evaluates to 1.8599999999999999) against the fixture value 1.86, which are 1 ULP apart. Verified by bisection: the test suite fails at 0 ULP and passes at 1 ULP. The suite was run twice at the final value to confirm determinism (no FMA/architecture variance); this test uses fixed, non-random input data.

Note that the previous 0.01 absolute tolerance was roughly 15 orders of magnitude looser than the actual error, so this change meaningfully tightens the assertion.

Only test/test.js is modified; no other files are touched.

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 assertion message follows the convention established in the already-migrated sibling package stats/incr/mpcorr, where the converted assertion uses 'returns expected value' while the surrounding untouched assertions keep 'returns expected value for window '+i.
  • Verification: make test TESTS_FILTER=".*/stats/incr/nanmrange/.*" passes (102/102), and make eslint-tests TESTS_FILTER=".*/stats/incr/nanmrange/.*" is clean.

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 written by Claude Code, which surveyed the repository for remaining tolerance-based tests, mirrored the idiom used by already-migrated packages, and determined the minimum passing ULP bound by bisection.


@stdlib-js/reviewers


Generated by Claude Code

@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 20, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

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