Skip to content

test: migrate stats/base/dists/geometric/stdev to ULP-based assertions - #14385

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-geometric-stdev
Aug 19, 2026
Merged

test: migrate stats/base/dists/geometric/stdev to ULP-based assertions#14385
kgryte merged 1 commit into
developfrom
kgryte/ulp-geometric-stdev

Conversation

@kgryte

@kgryte kgryte commented Aug 18, 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 test suites for stats/base/dists/geometric/stdev from relative tolerance assertions to ULP difference assertions, as described in [RFC]: Migrate math/base/special packages from relative tolerance testing to ULP difference testing (tracking issue) #11352.
  • replaces the delta/tol computation (previously 1.0 * EPS * abs( expected[ i ] )) and the associated t.ok( delta <= tol, ... ) / exact-equality branch with a single t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ) assertion.
  • adds a require for @stdlib/assert/is-almost-same-value and removes the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires.

The same change is applied to both test/test.js and test/test.native.js.

ULP bound: 1 ULP, for the "the function returns the standard deviation of a geometric distribution" test in both test/test.js and test/test.native.js. This is the measured minimum over the full fixture set (1000 values, test/fixtures/python/data.json); the observed ULP difference distribution is {0: 717, 1: 283}. Lowering the bound to 0 causes 283 test cases to fail, so 1 is the tightest bound which passes. The suite was run twice at the final bound to confirm the result is deterministic.

Only the two test files are changed; no source, documentation, or fixture files were touched.

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.

  • test/test.native.js is skipped locally, as the native add-on was not built in this environment. The ULP bound in test/test.native.js mirrors the bound measured for the JavaScript implementation, consistent with prior conversions in this family (e.g., stats/base/dists/negative-binomial/cdf, stats/base/dists/frechet/mode). As an additional check, the C implementation (sqrt( 1.0-p ) / p, per src/main.c) was compiled standalone and evaluated over the full fixture set; its results are bitwise identical to the JavaScript implementation for all 1000 fixture values, so the same bound applies.
  • The if ( y === expected[i] ) exact-equality fast path was removed, as isAlmostSameValue already returns true for exactly equal values.

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

This PR was authored by Claude Code, running as an automated task. The ULP bound was determined empirically by measuring the ULP difference across the full fixture set and verifying that the next lower bound fails.


@stdlib-js/reviewers


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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/geometric/stdev $\\color{green}166/166$
$\\color{green}+100.00\\%$
$\\color{green}9/9$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}166/166$
$\\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 Aug 19, 2026
@kgryte
kgryte marked this pull request as ready for review August 19, 2026 07:00
@kgryte
kgryte requested a review from a team August 19, 2026 07:00
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 19, 2026
@kgryte
kgryte merged commit 9c96a01 into develop Aug 19, 2026
82 checks passed
@kgryte
kgryte deleted the kgryte/ulp-geometric-stdev branch August 19, 2026 07:01
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Aug 19, 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