Skip to content

test: migrate stats/base/dists/laplace/logcdf to ULP-based assertions - #14141

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-laplace-logcdf
Aug 10, 2026
Merged

test: migrate stats/base/dists/laplace/logcdf to ULP-based assertions#14141
kgryte merged 1 commit into
developfrom
kgryte/ulp-laplace-logcdf

Conversation

@kgryte

@kgryte kgryte commented Aug 10, 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/laplace/logcdf from relative tolerance testing to ULP difference testing, replacing the delta/tol comparisons in test/test.logcdf.js, test/test.factory.js, and test/test.native.js with isAlmostSameValue.
  • adds the @stdlib/assert/is-almost-same-value import and removes the now unused @stdlib/constants/float64/eps and @stdlib/math/base/special/abs imports.

Final ULP constant: 0 for every fixture group, in all three test files.

The ULP bound was measured rather than guessed: for every fixture value, the minimum ULP difference which admits the computed result was computed directly (searching upward from 0), and the maximum over the full fixture set was taken. Both the JavaScript and C implementations reproduce every Julia fixture value exactly, so the measured minimum is 0 ULP — the tightest bound expressible — for all of:

Fixture Values Previous tolerance Measured max ULP diff ULP constant
positive_mean 1000 1.0*EPS 0 0
negative_mean 1000 1.0*EPS 0 0
large_variance 1000 1.0*EPS 0 0

test/test.native.js was verified against a locally compiled add-on (make install-node-addons NODE_ADDONS_PATTERN='laplace/logcdf') so that it did not skip; the 0 ULP bound is therefore measured for the C implementation as well, not merely inherited from the JavaScript results. Each suite was run twice at the final bound to confirm determinism (no FMA/architecture variation); all assertions pass on every run (test.logcdf.js: 3013, test.factory.js: 3018, test.native.js: 3013, test.js: 3).

Only the three test files are changed; the implementation and fixtures are untouched.

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.

Opened as a draft pending maintainer review of the 0 ULP bound. A bound of 0 requires bit-for-bit agreement with the fixtures; there is existing precedent in the repo (stats/base/dists/weibull/logcdf, stats/base/dists/uniform/entropy, math/base/special/covercos, and math/base/special/asec all use 0 for fixture groups which match exactly), and the results here are deterministic IEEE-754 in both the JavaScript and C implementations. If maintainers would prefer a 1 ULP margin in test/test.native.js as a hedge against compiler/architecture variation in the C build, that is a one-character change.

Two environment notes, neither affecting the diff:

  • The editorconfig-checker stage of the local pre-commit hook could not run, because it downloads its binary from a GitHub release which was not reachable from this environment. EditorConfig conformance was instead verified manually for the changed files (LF line endings, UTF-8, tab indentation, no trailing whitespace introduced, final newline present), and make eslint-tests TESTS_FILTER=".*/stats/base/dists/laplace/logcdf/.*" passes cleanly.
  • make install-node-modules fails in this environment because two transitive dependencies request registry versions which are not resolvable here (es-object-atoms@^1.1.2, hasown@^2.0.4; the registry as seen from this environment publishes at most 1.1.1 and 2.0.2 respectively). Installing with temporary local overrides pinning those two shims produced a working toolchain; the override was reverted before committing and is not part of this pull request. Flagging it in case CI hits the same resolution failure.

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 running as an unattended scheduled task: it selected the package, studied prior conversions in the repo to match the established idiom, applied the test migration, measured the minimum ULP bound empirically, and verified tests and linting locally.


@stdlib-js/reviewers


Generated by Claude Code

@stdlib-bot stdlib-bot added Good First PR A pull request resolving a Good First Issue. Statistics Issue or pull request related to statistical functionality. labels Aug 10, 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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/laplace/logcdf $\\color{green}291/291$
$\\color{green}+100.00\\%$
$\\color{green}23/23$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}291/291$
$\\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 Aug 10, 2026
@kgryte
kgryte marked this pull request as ready for review August 10, 2026 20:50
@kgryte
kgryte requested a review from a team August 10, 2026 20:50
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 10, 2026
@kgryte
kgryte merged commit a2e365c into develop Aug 10, 2026
82 checks passed
@kgryte
kgryte deleted the kgryte/ulp-laplace-logcdf branch August 10, 2026 20:51
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Aug 10, 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