Skip to content

test: migrate stats/base/dists/uniform/median to ULP-based assertions - #15418

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-stats-base-dists-uniform-median
Sep 22, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-stats-base-dists-uniform-median

Conversation

@kgryte

@kgryte kgryte commented Sep 22, 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/base/dists/uniform/median from relative tolerance testing to ULP difference testing.
  • replaces the delta/tol comparison in test/test.js and test/test.native.js with t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' );, adding the @stdlib/assert/is-almost-same-value require and removing the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires.

Final ULP constant: 0 for both test/test.js and test/test.native.js.

How the minimum was measured: the conversion started from a bound of 64, and the maximum ULP distance between the returned values and the Julia fixture values was then measured across the full fixture set (1000 values). That maximum is 0 — every returned value matches its fixture bit-for-bit — so 0 is both the measured minimum and the tightest bound expressible. This is expected, since the JavaScript implementation computes 0.5 * ( a + b ) and the C implementation computes ( a + b ) / 2.0; scaling by a power of two is exact, so both round identically.

The native add-on was built locally so that test/test.native.js actually executed rather than being skipped. The full suite (1008 assertions in test.js, 1008 in test.native.js) was run twice at the final bound with identical results, confirming determinism.

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 two test files are modified; no source, fixture, or documentation changes.

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 as part of an automated, maintainer-configured task for migrating packages to ULP-based test assertions. The conversion mirrors the idiom established in previously merged migrations (e.g. stats/base/dists/triangular/mean), and the ULP bound was determined empirically by measuring ULP distances over the fixtures and running the package's test suite.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01H7wkNLFGNTxtsRbFVDWC6b

Replace relative tolerance comparisons with `isAlmostSameValue` ULP
difference assertions in `test.js` and `test.native.js`. Both the
JavaScript and C implementations reproduce the Julia fixtures exactly,
so the minimum required ULP bound is 0.

Ref: #11352

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/uniform/median $\\color{green}175/175$
$\\color{green}+100.00\\%$
$\\color{green}7/7$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}175/175$
$\\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 22, 2026
@kgryte
kgryte marked this pull request as ready for review September 22, 2026 09:00
@kgryte
kgryte requested a review from a team September 22, 2026 09:00
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Sep 22, 2026
@kgryte
kgryte merged commit 2b7b08f into develop Sep 22, 2026
86 checks passed
@kgryte
kgryte deleted the kgryte/ulp-stats-base-dists-uniform-median branch September 22, 2026 09:00
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Sep 22, 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