Skip to content

test: migrate stats/base/dists/kumaraswamy/stdev to ULP-based assertions - #15533

Merged
kgryte merged 1 commit into
developfrom
claude/great-brahmagupta-pgw8zk
Sep 25, 2026
Merged

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

Conversation

@kgryte

@kgryte kgryte commented Sep 25, 2026

Copy link
Copy Markdown
Member

Ref #11352.

Description

What is the purpose of this pull request?

This pull request:

  • migrates the tests for stats/base/dists/kumaraswamy/stdev from computed relative-tolerance assertions to ULP-based assertions, per [RFC]: Migrate math/base/special packages from relative tolerance testing to ULP difference testing (tracking issue) #11352.
  • replaces the delta/tol (EPS-scaled) comparisons in test/test.js and test/test.native.js with t.strictEqual( isAlmostSameValue( y, expected[ i ], N ), true, 'returns expected value' ), adding the @stdlib/assert/is-almost-same-value require and dropping the now-unused @stdlib/constants/float64/eps and @stdlib/math/base/special/abs requires.
  • only touches the two test files; no source, fixture, or documentation changes.

ULP constants

Both test files use a bound of 10564 ULP, which is the measured minimum over the full 1000-point Julia fixture set:

File Previous tolerance ULP bound Measured minimum
test/test.js 10000 * EPS * abs( expected[ i ] ) 10564 10564
test/test.native.js 18500 * EPS * abs( expected[ i ] ) 10564 10564

The bound was tightened by bisection over the fixture set and then confirmed against the test suite itself: both files pass at 10564 and fail with exactly one failing assertion at 10563 (worst case: a = 0.5981637562600661, b = 0.00034899264986798517). The suites were run twice at the final bound with identical results.

The native add-on was built locally (node-gyp rebuild) so that test/test.native.js actually executed rather than being skipped; it required the same bound as the JavaScript implementation, so the previously more lenient native tolerance has been tightened to match. Measurements were taken on x86-64 Linux, Node.js v22.

The existing comment explaining why a high tolerance is needed (compounding error in σ = √(m₂ - m₁²)) has been preserved above the fixture loop, since it also explains the relatively large ULP 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?

  • test/test.native.js previously allowed a more lenient tolerance than test/test.js (18500 vs. 10000 times EPS). On x86-64 Linux the locally built add-on needs no more headroom than the JavaScript implementation, so both files now use 10564. If that extra headroom was added for a specific platform, reviewers may prefer a larger bound for the native test.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

Opened as a draft pending review of the ULP bounds above.

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 written by Claude Code running as an unattended scheduled task: it selected the package, studied previously merged ULP migrations for the established idiom, performed the test conversion, and measured the minimum ULP bound empirically.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01K4KbwigC41ecFnMXdUkDQM


Generated by Claude Code

…tions

Replaces the computed relative-tolerance assertions in
`test/test.js` and `test/test.native.js` with
`@stdlib/assert/is-almost-same-value`. The ULP bound (10564) is the
measured minimum over the full 1000-point Julia fixture set for both
the JavaScript and native implementations.

Ref: #11352

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K4KbwigC41ecFnMXdUkDQM

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: skipped
  - task: lint_markdown_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@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 25, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/kumaraswamy/stdev $\\color{green}188/188$
$\\color{green}+100.00\\%$
$\\color{green}5/5$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}188/188$
$\\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 25, 2026
@kgryte
kgryte marked this pull request as ready for review September 25, 2026 10:58
@kgryte
kgryte requested a review from a team September 25, 2026 10:58
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Sep 25, 2026
@kgryte
kgryte merged commit 6902d5d into develop Sep 25, 2026
82 checks passed
@kgryte
kgryte deleted the claude/great-brahmagupta-pgw8zk branch September 25, 2026 11:00
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Sep 25, 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