Skip to content

test: migrate stats/base/dists/geometric/quantile to ULP-based assertions - #16078

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-geometric-quantile
Oct 12, 2026
Merged

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

Conversation

@kgryte

@kgryte kgryte commented Oct 12, 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/geometric/quantile from relative tolerance testing to ULP difference testing.
  • replaces the delta/tol comparisons with isAlmostSameValue( y, expected[ i ], 0 ) in test/test.quantile.js, test/test.factory.js, and test/test.native.js, adding the @stdlib/assert/is-almost-same-value import and removing the now-unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps imports.

ULP bounds

The final ULP constant is 0 for all six migrated fixture loops (small p and large p, across the main, factory, and native tests).

This value was tightened empirically rather than assumed. Starting from a high bound, the minimum required ULP value was measured per fixture case over the full fixture set (1000 cases in small_p.json and 1000 cases in large_p.json) for the JavaScript implementation, the factory-generated function, and the compiled C implementation. The measured maximum required ULP difference was 0 in every case, i.e. all three implementations reproduce the Julia reference values exactly.

This is expected, as the quantile function of a geometric distribution returns non-negative integers which are exactly representable in double-precision. It also preserves the strictness of the previous assertions, as the former 1.0 * EPS * abs( expected[ i ] ) tolerance was already below one integer unit for the fixture magnitudes involved.

The full package suite was run twice at the final bound, with identical results each time (6037 assertions, all passing, no failures), confirming the bound is deterministic and not sensitive to FMA/architecture differences.

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.

Verification notes:

  • make test TESTS_FILTER=".*/stats/base/dists/geometric/quantile/.*" passes (run twice; 6037 assertions, 0 failures).
  • make lint-javascript-tests TESTS_FILTER=".*/stats/base/dists/geometric/quantile/.*" is clean.
  • The native add-on was compiled locally (make install-node-addons NODE_ADDONS_PATTERN=stats/base/dists/geometric/quantile) so that test/test.native.js was actually exercised rather than skipped; its 2011 assertions pass against the C implementation.
  • Only test files are modified; no implementation, documentation, or fixture changes.
  • The editorconfig pre-commit hook could not run in this environment, as it attempts to download a binary from a repository outside the session's allowed scope. Compliance was instead checked by hand (LF endings, tab indentation, UTF-8, no trailing whitespace, final newline present).

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 running as an unattended scheduled task. It selected the package, studied the idiom used by previously merged conversions in the same family, applied the test migration, measured the minimum ULP bound empirically over the full fixture set, and verified tests and linting locally.


@stdlib-js/reviewers


Generated by Claude Code

…rtions

Replace relative tolerance assertions with ULP difference assertions
using `@stdlib/assert/is-almost-same-value`. The quantile function
returns non-negative integers, and both the JavaScript and C
implementations reproduce the Julia fixture values exactly, so the
minimum required ULP value is `0`.

Ref: #11352

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/geometric/quantile $\\color{green}309/309$
$\\color{green}+100.00\\%$
$\\color{green}27/27$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}309/309$
$\\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 13:42
@kgryte
kgryte requested a review from a team October 12, 2026 13:42
@kgryte
kgryte merged commit 49bccbc into develop Oct 12, 2026
66 checks passed
@kgryte
kgryte deleted the kgryte/ulp-geometric-quantile branch October 12, 2026 13:43
@stdlib-bot stdlib-bot added Needs Review A pull request which needs code review. and removed Needs Review A pull request which needs code review. labels 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