Skip to content

test: migrate stats/incr/mmeanstdev to ULP-based assertions - #16257

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

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

Conversation

@kgryte

@kgryte kgryte commented Oct 19, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

The package had a single computed-tolerance assertion, covering the corrected sample standard deviation returned when the accumulator is invoked without an input value:

delta = abs( actual[ 1 ] - expected[ 1 ] );
tol = EPS * expected[ 1 ];
t.strictEqual( delta < tol, true, 'expected: '+expected[ 1 ]+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' );

which is now

t.strictEqual( isAlmostSameValue( actual[ 1 ], expected[ 1 ], 0 ), true, 'returns expected value' );

The @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires, along with the now-unused delta and tol declarations, were removed, as they were only used by the migrated assertion.

ULP bound

  • Final ULP constant: 0

The bound was tightened empirically. Starting from a high bound and lowering it, the accumulator's returned standard deviation proved bit-identical to the expected value (sqrt( 19.0 )) for the tested fixture:

actual[1]   = 4.358898943540674
expected[1] = 4.358898943540674
exactly equal: true
minimum ULP = 0

0 is therefore the measured minimum and the tightest bound expressible. This matches the bound used by the already-migrated sibling package stats/incr/mmeanvar, whose test is structurally identical (same [ 2.0, 3.0, 10.0 ] dataset and window size).

Verification

  • make test TESTS_FILTER=".*/stats/incr/mmeanstdev/.*" — 424/424 passing, run three times with identical results, confirming the bound is deterministic.
  • eslint with etc/eslint/.eslintrc.tests.js — clean, zero findings.
  • Only the package's test file is changed (+2 / -7).

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.

Opened as a draft for review of the migration idiom before marking ready.

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 authored by Claude Code running as an unattended scheduled task. It selected the package, mirrored the migration idiom from the already-converted stats/incr/mmeanvar, measured the minimum ULP bound empirically, and verified the tests and linting.


@stdlib-js/reviewers


Generated by Claude Code

Replace the computed relative-tolerance check for the corrected sample
standard deviation with an ULP-based assertion using
`@stdlib/assert/is-almost-same-value`, matching the idiom already used by
`stats/incr/mmeanvar`.

The accumulator returns a bit-exact result for the tested fixture, so the
assertion uses the tightest possible bound of 0 ULP.

Ref: #11352

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/incr/mmeanstdev $\\color{green}327/327$
$\\color{green}+100.00\\%$
$\\color{green}38/38$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}327/327$
$\\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 24, 2026
@kgryte
kgryte marked this pull request as ready for review October 24, 2026 02:43
@kgryte
kgryte requested a review from a team October 24, 2026 02:43
@kgryte kgryte closed this Oct 24, 2026
@kgryte
kgryte deleted the kgryte/ulp-stats-incr-mmeanstdev branch October 24, 2026 02:44
@kgryte kgryte added the autoclose: Already Resolved Pull request which should be auto-closed due proposed changes duplicating already included changes. label Oct 24, 2026
@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 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autoclose: Already Resolved Pull request which should be auto-closed due proposed changes duplicating already included changes. 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