Skip to content

test: migrate stats/base/dists/frechet/quantile to ULP-based assertions - #15574

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-frechet-quantile
Sep 27, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-frechet-quantile

Conversation

@kgryte

@kgryte kgryte commented Sep 26, 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/frechet/quantile from relative tolerance testing to ULP difference testing, replacing the delta/tol comparisons in the Julia fixture loops with isAlmostSameValue( y, expected[ i ], N ) assertions.
  • updates test/test.quantile.js, test/test.factory.js, and test/test.native.js. Only test files are changed; no implementation, documentation, or fixture changes.

The ULP bounds are the measured minimums over the full fixture sets (each set has 1000 values). The implementation returns bit-identical values to the Julia fixtures for every value in every set, so the minimum is 0 and no lower bound exists:

Fixture Previous tolerance (JS) Previous tolerance (native) ULP bound Minimum?
large_shape.json 1.0 * EPS * abs( expected[ i ] ) 300.0 * EPS * abs( expected[ i ] ) 0 yes (0 is the floor)
large_scale.json 1.0 * EPS * abs( expected[ i ] ) 1500.0 * EPS * abs( expected[ i ] ) 0 yes (0 is the floor)
both_large.json 1.0 * EPS * abs( expected[ i ] ) 4100.0 * EPS * abs( expected[ i ] ) 0 yes (0 is the floor)

The native add-on was built locally so that test/test.native.js actually ran rather than being skipped. The C implementation returns bit-identical values to the JavaScript implementation for every fixture value (both compute m + s*pow( -ln( p ), -1/alpha ) via @stdlib/math/base/special/pow and @stdlib/math/base/special/ln, so neither depends on the system libm), and the factory-created function returns bit-identical values to the main export. Accordingly, test/test.native.js uses the same bounds as the JavaScript tests, which tightens the previous native tolerances considerably.

make test TESTS_FILTER=".*/stats/base/dists/frechet/quantile/.*" passes (9065 assertions across the four test files, no skips and no failures), and was run twice at the final bounds with identical results. make lint-javascript-tests TESTS_FILTER=".*/stats/base/dists/frechet/quantile/.*" is clean.

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?

The previous native tolerances (300/1500/4100 EPS) were far looser than the JavaScript ones (1.0 EPS). Since the C implementation measures bit-identical to both the JavaScript implementation and the fixtures here, this PR drops the native bounds to 0 alongside the JavaScript ones. If those looser native tolerances were originally chosen to accommodate a platform not represented here, please say so and the native bounds can be relaxed.

Other

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

The idiom mirrors the already-migrated sibling packages stats/base/dists/cosine/quantile and stats/base/dists/frechet/pdf.

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 performed the mechanical test migration, measured the minimum ULP bounds against the fixture sets, and verified the tests and linting locally.


@stdlib-js/reviewers


Generated by Claude Code

…ions

Replace relative tolerance comparisons in the Julia fixture loops with
`isAlmostSameValue` ULP difference assertions. The JavaScript and C
implementations both return bit-identical values to the fixtures across
all three fixture sets, so the measured minimum ULP bound is 0.

Ref: #11352

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/frechet/quantile $\\color{green}300/300$
$\\color{green}+100.00\\%$
$\\color{green}27/27$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}300/300$
$\\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 27, 2026
@kgryte
kgryte marked this pull request as ready for review September 27, 2026 06:26
@kgryte
kgryte requested a review from a team September 27, 2026 06:26
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Sep 27, 2026
@kgryte
kgryte merged commit 864fee6 into develop Sep 27, 2026
66 checks passed
@kgryte
kgryte deleted the kgryte/ulp-frechet-quantile branch September 27, 2026 06:27
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Sep 27, 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