Skip to content

test: migrate stats/base/dists/uniform/stdev to ULP-based assertions - #15338

Draft
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-uniform-stdev
Draft

kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-uniform-stdev

Conversation

@kgryte

@kgryte kgryte commented Sep 19, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

Details:

  • Converted test/test.js and test/test.native.js.
  • Removed the @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires, along with the delta/tol computations, replacing them with a single t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); assertion.
  • Final ULP constant: 1 in both test/test.js and test/test.native.js.
  • Measured minimum: starting from a loose bound and tightening, the maximum observed ULP difference across the full 1000-value Julia fixture set is 1 for both the JavaScript and the native C implementation. 1 is therefore the tightest bound possible: at 0, 401 of the 1000 fixture assertions fail in each test file (worst case a = 5.6401776468072224, b = 8.157518985003108, returning 0.7266938496247836 versus an expected 0.7266938496247837). The ULP difference distribution over the fixture set is 599 values at 0 ULP and 401 values at 1 ULP. The previous relative tolerance was 1.0 * EPS, which is consistent with a 1 ULP bound.
  • Both implementations compute sqrt( 1/12 ) * ( b-a ) as a single subtraction followed by a single multiplication by the same constant, so the JavaScript and native implementations return bitwise-identical results for every fixture value (confirmed empirically: the 0 ULP run fails the identical 401 assertions in both files). Both files therefore use the same bound.
  • Both test suites were run twice at the final ULP value to confirm determinism (no FMA/architecture-dependent variation). With the native add-on built locally, test/test.js and test/test.native.js each pass 1008/1008 assertions on both runs.
  • Linting is clean: both files pass ESLint using the project's test configuration (etc/eslint/.eslintrc.tests.js).
  • No non-test files were modified.

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.

No.

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 studied previously merged ULP migrations in the same package family, applied the same idiom here, and empirically determined and verified the minimum ULP bound.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01D74AN8LAoh4Bg1iYcc83dj


Generated by Claude Code

Replace the relative tolerance (`EPS`-based) assertions in `test/test.js`
and `test/test.native.js` with ULP difference assertions using
`@stdlib/assert/is-almost-same-value`.

The maximum observed ULP difference across the full 1000-value Julia
fixture set is 1 for both the JavaScript and the native C implementation,
so both files use a bound of 1 ULP.

Ref: #11352

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/uniform/stdev $\\color{green}184/184$
$\\color{green}+100.00\\%$
$\\color{green}7/7$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}184/184$
$\\color{green}+100.00\\%$

The above coverage report was generated for the changes in this PR.

Copy link
Copy Markdown
Member

⚠️ Issue Reference Review

An automated check found potentially unrelated issue/PR references in this PR:

Reference Assessment Reasoning
#11352 suspicious Issue #11352 is an RFC explicitly scoped to migrating math/base/special packages from relative-tolerance to ULP-based testing (its own instructions say to search for a package "in math/base/special"). This PR migrates tests for stats/base/dists/uniform/stdev, which is outside the issue's stated scope.

Why this matters: GitHub automatically closes issues referenced with
closing keywords (Resolves, Closes, Fixes) when the PR is merged. Incorrect
references can accidentally close unrelated issues.

What to do:

  • If the reference is correct, no action needed. This check may produce
    false positives.
  • If the reference is incorrect, please update your PR description.

This assessment was generated by an AI model and is informational only.


Generated by Claude Code

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.

4 participants