Skip to content

test: migrate stats/base/dists/planck/cdf to ULP-based assertions - #15650

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-planck-cdf
Sep 30, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-planck-cdf

Conversation

@kgryte

@kgryte kgryte commented Sep 29, 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 unit tests for @stdlib/stats/base/dists/planck/cdf from relative tolerance checks (delta <= tol, computed as 1.0 * EPS * abs( expected[ i ] )) to ULP-based assertions using @stdlib/assert/is-almost-same-value.
  • Applies the migration to test/test.cdf.js, test/test.factory.js, and test/test.native.js (the three files containing fixture loops with computed tolerances). test/test.js only performs exact comparisons and is left unchanged.
  • Removes the now-unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires, along with the delta and tol declarations.

ULP bounds

The bounds are the measured minima over the full fixture sets, determined by computing the maximum ULP difference between the actual and expected values for every fixture element:

Fixture ULP bound Notes
small_lambda.json 1 Max measured ULP difference is exactly 1 (a single element, x = 1, lambda ≈ 0.0431137); 0 fails.
large_lambda.json 0 All 1000 elements match exactly; 0 is the minimum possible.

The same bounds are used in test.cdf.js, test.factory.js, and test.native.js.

Verification

  • Package tests are green, and the suite was run twice at the final bounds with identical results (2010 + 2014 + 3 assertions passing; test.native.js is skipped, as the native add-on is not built in this environment).
  • Minimality was confirmed programmatically: lowering the small-lambda bound to 0 fails for both the main and factory implementations, while 1 passes.
  • make lint-javascript-files ... ESLINT_CONF=etc/eslint/.eslintrc.tests.js is clean.
  • Only the three test files are changed.

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 test.native.js bounds mirror the JavaScript bounds, following the convention in already-converted packages (e.g., stats/base/dists/poisson/cdf), but could not be measured here because the native add-on was not built. Please flag if you would prefer them verified against a built add-on first.

Other

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

The inline integer bound idiom (rather than a named ULP constant) mirrors the prevailing convention in stats/base/dists, where all already-converted test files use inline literals.

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 surveyed prior converted packages to match the established idiom, applied the test edits, and measured the minimum ULP bounds empirically over the fixture sets.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_015ih3rRmRJdoJ4wWMPTY83i


Generated by Claude Code

Replaces the relative-tolerance comparisons (`delta <= tol`) in the
fixture loops with `@stdlib/assert/is-almost-same-value` assertions.
The ULP bounds are the measured minima over the full fixture sets: `1`
for the small `lambda` fixtures and `0` (i.e., exact) for the large
`lambda` fixtures.

Ref: #11352

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ih3rRmRJdoJ4wWMPTY83i
@stdlib-bot stdlib-bot added the Good First PR A pull request resolving a Good First Issue. label Sep 29, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Hello! 👋

We've noticed that you've been opening a number of PRs addressing good first issues. Thank you for your interest and enthusiasm!

Now that you've made a few contributions, we suggest no longer working on good first issues. Instead, we encourage you to prioritize cleaning up any PRs which have yet to be merged and then proceed to work on more involved tasks.

Not only does this ensure that other new contributors can work on things and get ramped up on all things stdlib, it also ensures that you can spend your time on more challenging problems. 🚀

For ideas for future PRs, feel free to search the codebase for TODOs and FIXMEs and be sure to check out other open issues on the issue tracker. Cheers!

@stdlib-bot stdlib-bot added the Statistics Issue or pull request related to statistical functionality. label Sep 29, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/planck/cdf $\\color{green}279/279$
$\\color{green}+100.00\\%$
$\\color{green}25/25$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}279/279$
$\\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 30, 2026
@kgryte
kgryte marked this pull request as ready for review September 30, 2026 05:42
@kgryte
kgryte requested a review from a team September 30, 2026 05:42
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Sep 30, 2026
@kgryte
kgryte merged commit 51b97d8 into develop Sep 30, 2026
82 checks passed
@kgryte
kgryte deleted the kgryte/ulp-planck-cdf branch September 30, 2026 05:43
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Sep 30, 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