Skip to content

test: migrate stats/strided/sstdevwd to ULP-based assertions - #15302

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-sstdevwd
Sep 18, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-sstdevwd

Conversation

@kgryte

@kgryte kgryte commented Sep 17, 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/strided/sstdevwd from relative tolerance testing to ULP difference testing, per [RFC]: Migrate math/base/special packages from relative tolerance testing to ULP difference testing (tracking issue) #11352.
  • replaces the delta/tol comparisons in test/test.sstdevwd.js, test/test.ndarray.js, test/test.sstdevwd.native.js, and test/test.ndarray.native.js with t.strictEqual( isAlmostSameValuef( v, expected, 1 ), true, 'returns expected value' ), adding the @stdlib/number/float32/base/assert/is-almost-same-value require and removing the now unused @stdlib/math/base/special/abs and @stdlib/constants/float32/eps requires.

Because this package operates on single-precision floating-point numbers, the single-precision assertion utility @stdlib/number/float32/base/assert/is-almost-same-value is used, matching already-migrated single-precision packages (e.g., stats/base/snanstdevpn, stats/base/snanstdev).

Final ULP constant: 1 for all four assertions (one assertion × four test files).

The bound was tightened by starting high (64) and lowering it to the minimum integer which still passes over the full set of test cases. The measured ULP difference was 1 for every assertion, in both the JavaScript and the C implementation:

test file assertions measured max ULP diff ULP bound used
test.sstdevwd.js 1 1 1
test.ndarray.js 1 1 1
test.sstdevwd.native.js 1 1 1
test.ndarray.native.js 1 1 1

A bound of 0 fails (the returned value and the reference value are adjacent single-precision numbers: 2.986078977584839 vs. 2.9860787391662598), so 1 is the tightest passing bound.

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.

  • Only the four test files are changed; no source, fixture, or documentation changes.
  • make test TESTS_FILTER=".*/stats/strided/sstdevwd/.*" was run twice at the final ULP bound with identical results (41 passing, 0 failing), to rule out arch/FMA nondeterminism.
  • The native add-on was not built in the development environment used here, so test/test.sstdevwd.native.js and test/test.ndarray.native.js reported as skipped. To confirm the 1 ULP bound for the C implementation, src/main.c (together with stats/strided/svariancewd, math/base/special/sqrtf, and strided/base/stride2offset) was compiled standalone and the same cases were evaluated; the measured ULP difference was 1 at -O0, -O2, and -O3 -march=native -ffp-contract=fast, with the C implementation returning bit-for-bit the same value as the JavaScript implementation. Reviewers may wish to confirm the native tests on CI, where the add-on is actually built.
  • ESLint was run over the package's test/ directory using the repository's own test configuration (make eslint-tests): 0 errors, 0 warnings across all five test files. lint-filenames and lint-license-headers-files also passed.
  • lint-editorconfig could not be executed, because editorconfig-checker downloads its binary from GitHub releases, which was not reachable from this environment. The changed files were instead verified programmatically against every rule .editorconfig applies to *.js: LF line endings, UTF-8 encoding, tab indentation, no trailing whitespace, and a final newline.

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 selected the package, mirrored the idiom used by already-migrated packages, measured the minimum passing ULP bound over the full set of test cases, and verified the tests and linting locally.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01QMgxvv2enPsho3aBY8NYSV


Generated by Claude Code

Migrate the tests for `stats/strided/sstdevwd` from relative tolerance
testing to ULP difference testing, replacing the `delta`/`tol`
comparisons with `isAlmostSameValuef` assertions using the minimum
required ULP bound of `1`.

Ref: #11352

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QMgxvv2enPsho3aBY8NYSV
@stdlib-bot stdlib-bot added the Good First PR A pull request resolving a Good First Issue. label Sep 17, 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 stdlib-bot added the Statistics Issue or pull request related to statistical functionality. label Sep 17, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/strided/sstdevwd $\\color{green}362/362$
$\\color{green}+100.00\\%$
$\\color{green}13/13$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}362/362$
$\\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 Sep 18, 2026
@kgryte
kgryte marked this pull request as ready for review September 18, 2026 06:30
@kgryte
kgryte requested a review from a team September 18, 2026 06:30
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Sep 18, 2026
@kgryte
kgryte merged commit b6f0b5f into develop Sep 18, 2026
82 checks passed
@kgryte
kgryte deleted the kgryte/ulp-sstdevwd branch September 18, 2026 06:31
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Sep 18, 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