Skip to content

test: migrate stats/base/snanstdevch to ULP-based assertions - #16125

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-stats-base-snanstdevch
Oct 13, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-stats-base-snanstdevch

Conversation

@kgryte

@kgryte kgryte commented Oct 13, 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/base/snanstdevch from relative tolerance testing to ULP difference testing.
  • replaces the delta = abs( v - expected ); tol = 1.0 * EPS * abs( expected ); comparisons with isAlmostSameValuef( v, expected, <ULP> ) assertions, adding the @stdlib/number/float32/base/assert/is-almost-same-value require and dropping the now unused @stdlib/math/base/special/abs and @stdlib/constants/float32/eps requires.

As the package returns single-precision results, this follows the already migrated sibling packages stats/base/snanstdevyc, stats/base/snanstdevwd, and stats/base/snanstdevpn, which use the single-precision @stdlib/number/float32/base/assert/is-almost-same-value rather than the double-precision assertion.

Four test files are modified (test/test.snanstdevch.js, test/test.snanstdevch.native.js, test/test.ndarray.js, and test/test.ndarray.native.js); test/test.js contains no tolerance-based assertions and is left unchanged. The native test files receive the same bound as their JavaScript counterparts, as the C implementation was measured to return bit-identical results for these inputs.

ULP bounds

Each of the eight migrated assertions has a measured ULP difference of exactly 1, so the final bound is 1 throughout. This was verified to be minimal: lowering any bound to 0 fails the suite.

Test file Assertions ULP
test/test.snanstdevch.js 2 1
test/test.snanstdevch.native.js 2 1
test/test.ndarray.js 2 1
test/test.ndarray.native.js 2 1

This matches the bound used by the migrated sibling packages stats/base/snanstdevyc and stats/base/snanstdevwd, which exercise the same datasets against a different summation algorithm.

The native add-on was compiled locally (make install-node-addons NODE_ADDONS_PATTERN=snanstdevch) so that the .native.js test files actually execute rather than being skipped. The full suite was run twice at the final bounds with identical results (149 assertions, all passing, across all five test files).

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.

make lint-javascript-tests TESTS_FILTER=".*/stats/base/snanstdevch/.*" passes cleanly. The migration also removes two over-long lines per test file, matching the line lengths of the already migrated sibling packages.

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, which performed the migration, measured the minimum ULP bounds empirically, and verified the test suite.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01KdBJCQoMkXncAATzNSWsej


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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/snanstdevch $\\color{green}365/365$
$\\color{green}+100.00\\%$
$\\color{green}14/14$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}365/365$
$\\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 13, 2026
@kgryte
kgryte marked this pull request as ready for review October 13, 2026 22:52
@kgryte
kgryte requested a review from a team October 13, 2026 22:52
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Oct 13, 2026
@kgryte
kgryte merged commit 4db5707 into develop Oct 13, 2026
82 checks passed
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Oct 13, 2026
@kgryte
kgryte deleted the kgryte/ulp-stats-base-snanstdevch branch October 13, 2026 22:54
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