Skip to content

test: migrate stats/base/dists/discrete-uniform/quantile to ULP-based assertions - #15926

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

kgryte merged 1 commit into
developfrom
claude/great-brahmagupta-80zvxe

Conversation

@kgryte

@kgryte kgryte commented Oct 5, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

The computed delta/tol comparisons in the fixture loops of test/test.quantile.js, test/test.factory.js, and test/test.native.js are replaced with isAlmostSameValue( y, expected[ i ], 0 ) assertions, and the now-unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires are dropped in favor of @stdlib/assert/is-almost-same-value. No other test cases were touched; the exact comparisons elsewhere in these files are unchanged. test/test.js contains no tolerance-based assertions and is therefore unmodified.

The ULP bound is the measured minimum over each full fixture set:

Fixture Measured max ULP diff ULP bound
fixtures/julia/small_range.json 0 0
fixtures/julia/medium_range.json 0 0
fixtures/julia/large_range.json 0 0

Each fixture set contains 1000 cases. Starting from a loose bound and tightening, every one of the 3000 cases is bit-identical to the Julia-generated expected value for both implementations under test (lib/main.js and lib/factory.js), so the measured maximum ULP difference is 0 and test.factory.js uses the same bound as test.quantile.js. Because maxULP = 0 requires isSameValue equality, it is the tightest integer bound attainable and no smaller value exists to check.

This result is expected: the quantile function evaluates a + floor( p*(b-a+1) ), which, for the integer supports exercised by the fixtures, is exactly representable in double precision.

The same bound holds for the C implementation. The native add-on was built locally (node-gyp rebuild) so that test/test.native.js actually runs rather than being skipped, and all 3007 of its assertions pass at 0 ULP. As a cross-check against FMA/arch sensitivity, the C expression was additionally evaluated over the same 3000 fixture cases in a standalone harness compiled both at -O2 and at -O3 -march=native -ffp-contract=fast; both produced bit-identical results for every case.

The suite was run twice at the final bound, with identical results both times (3016 + 3012 + 3 + 3007 assertions passing, 0 failing).

Note that the previous bound was 1.0 * EPS in all nine fixture loops; the 0 ULP bound is strictly tighter.

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.

  • make lint-javascript-tests TESTS_FILTER=".*/stats/base/dists/discrete-uniform/quantile/.*" is clean.
  • The idiom mirrors the already-converted sibling packages stats/base/dists/erlang/quantile and stats/base/dists/chisquare/quantile.
  • make lint-editorconfig-files could not run in this environment, as the editorconfig-checker binary could not be downloaded. The changed lines were checked by hand for tab indentation, trailing whitespace, line endings, and a final newline.

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, which also measured the minimum ULP bound empirically and ran the tests and linter.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01VdWTZQyfuCaFizioXQ6JKf


Generated by Claude Code

…ed assertions

Ref: #11352

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/discrete-uniform/quantile $\\color{green}299/299$
$\\color{green}+100.00\\%$
$\\color{green}27/27$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}299/299$
$\\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 00:19
@kgryte
kgryte requested a review from a team October 12, 2026 00:20
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Oct 12, 2026
@kgryte
kgryte merged commit 05da8d1 into develop Oct 12, 2026
82 checks passed
@kgryte
kgryte deleted the claude/great-brahmagupta-80zvxe branch October 12, 2026 00:20
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label 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