Skip to content

test: migrate stats/strided/sstdevch to ULP-based assertions - #16073

Merged
kgryte merged 1 commit into
developfrom
claude/great-brahmagupta-iobfav
Oct 12, 2026
Merged

kgryte merged 1 commit into
developfrom
claude/great-brahmagupta-iobfav

Conversation

@kgryte

@kgryte kgryte commented Oct 12, 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/sstdevch from relative tolerance testing to ULP difference testing.

Specifically, in test/test.sstdevch.js, test/test.ndarray.js, test/test.sstdevch.native.js, and test/test.ndarray.native.js:

  • adds a @stdlib/number/float32/base/assert/is-almost-same-value require (the single-precision variant, as the package returns single-precision results), and removes the now unused @stdlib/math/base/special/abs and @stdlib/constants/float32/eps requires.
  • removes the delta and tol computations, replacing t.strictEqual( delta <= tol, true, ... ) with t.strictEqual( isAlmostSameValuef( v, expected, 1 ), true, 'returns expected value' ).

This mirrors the already migrated sibling packages stats/strided/sstdev and stats/base/snanstdevyc, which use the same idiom and the same ULP bound. Only test files are changed; no implementation, documentation, or package.json changes were necessary. Exact comparisons (e.g., against 0.0, NaN, and in test/test.js) were left as-is.

Final ULP constant: 1 (used in all four test files, for both the JavaScript and the native assertions).

This is the measured minimum. The ULP difference between the returned value and the expected value was measured directly for each of the migrated assertions, for the JavaScript (lib/sstdevch.js, lib/ndarray.js) and native (lib/sstdevch.native.js, lib/ndarray.native.js) implementations, and is exactly 1 in every case. Tightening further fails: at an ULP bound of 0, the assertions fail; at 1, all pass.

Verification (locally, with the native add-on built via NODE_ADDONS_PATTERN="sstdevch" make install-node-addons, so that the *.native.js suites actually run rather than skip):

  • make test TESTS_FILTER=".*/stats/strided/sstdevch/.*" → 77 assertions, 77 passing, 0 failing.
  • The full suite was run twice at the final ULP bound of 1 with identical results, to confirm there is no FMA/architecture-dependent flakiness.
  • make lint-javascript-tests TESTS_FILTER=".*/stats/strided/sstdevch/.*" (ESLint, using etc/eslint/.eslintrc.tests.js) is clean on all changed files, as are the license-header and filename lints.

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 lint_editorconfig pre-commit check could not be run in this environment, as it attempts to download the editorconfig-checker binary from GitHub and outbound access to that repository was unavailable. The changed files were instead verified manually against .editorconfig (LF line endings, UTF-8, tab indentation, no trailing whitespace, final newline present).

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, running as an unattended scheduled task. The agent selected the package, mirrored the migration idiom from the already migrated sibling packages, measured the minimum ULP bound empirically, and verified the tests and lint locally.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01De2bMgapTNyqxjdw9XURSE


Generated by Claude Code

Replace the relative tolerance assertions in the package tests with ULP
difference assertions, per the migration described in #11352.

In `test/test.sstdevch.js`, `test/test.ndarray.js`,
`test/test.sstdevch.native.js`, and `test/test.ndarray.native.js`, add a
`@stdlib/number/float32/base/assert/is-almost-same-value` require (the
single-precision variant, as the package returns single-precision
results), remove the now unused `@stdlib/math/base/special/abs` and
`@stdlib/constants/float32/eps` requires, and replace the `delta`/`tol`
computations with `isAlmostSameValuef`.

The ULP bound is `1`, which is the measured minimum; the assertions fail
at a bound of `0`.

Ref: #11352

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/strided/sstdevch $\\color{green}350/350$
$\\color{green}+100.00\\%$
$\\color{green}13/13$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}350/350$
$\\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 12, 2026
@kgryte
kgryte marked this pull request as ready for review October 12, 2026 13:43
@kgryte
kgryte requested a review from a team October 12, 2026 13:43
@kgryte
kgryte merged commit cb94d72 into develop Oct 12, 2026
66 checks passed
@kgryte
kgryte deleted the claude/great-brahmagupta-iobfav branch October 12, 2026 13:44
@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 12, 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.

3 participants