Skip to content

test: migrate stats/base/dists/poisson/mgf to ULP-based assertions - #14499

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-stats-base-dists-poisson-mgf
Aug 22, 2026
Merged

test: migrate stats/base/dists/poisson/mgf to ULP-based assertions#14499
kgryte merged 1 commit into
developfrom
kgryte/ulp-stats-base-dists-poisson-mgf

Conversation

@kgryte

@kgryte kgryte commented Aug 21, 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 @stdlib/stats/base/dists/poisson/mgf from relative-tolerance assertions to ULP-based assertions using @stdlib/assert/is-almost-same-value, per the guidance in [RFC]: Migrate math/base/special packages from relative tolerance testing to ULP difference testing (tracking issue) #11352.
  • updates test/test.mgf.js, test/test.factory.js, and test/test.native.js to mirror the idiom used in previously converted packages (e.g. stats/base/dists/normal/mgf, stats/base/dists/normal/mean, stats/base/dists/weibull/cdf).
  • replaces the previous EPS * abs( expected[ i ] ) tolerance loops in all three files with t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' ).
  • drops the now-unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires.

test/test.js only asserts on the main export and the attached factory method and thus required no changes.

The tightest ULP bound was determined empirically by measuring, for every fixture value, the minimum N for which isAlmostSameValue( actual, expected, N ) returns true, and taking the maximum over the full Julia fixture set (3000 values across the small, medium, and large fixtures):

  • test/test.mgf.js: N = 0 ULP (measured maximum ULP difference: 0 across all three fixture groups).
  • test/test.factory.js: N = 0 ULP (measured maximum ULP difference: 0 across all three fixture groups).
  • test/test.native.js: N = 0 ULP, mirroring the JavaScript bound, consistent with previously merged conversions.

All 3000 fixture values match the Julia reference bit-for-bit, so 0 is both the measured maximum and the tightest bound expressible, and the previous tolerance branch was never taken.

test/test.js, test/test.mgf.js, and test/test.factory.js were each run twice at the final N = 0 (3, 3008, and 3009 assertions, respectively; all passing) to confirm the bound is deterministic. Linting with the repository's etc/eslint/.eslintrc.tests.js configuration is clean for all four test files, and 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 native add-on could not be built in the environment used to author this PR, so test/test.native.js was exercised in skipped form only and its N = 0 bound is mirrored from the JavaScript measurement rather than measured against the C implementation. Reviewers may wish to confirm the native tests pass at N = 0 in an environment with add-ons built. This is the main reason the PR is opened as a draft.

Other

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

No.

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

This PR was authored by Claude Code (Anthropic) running as an unattended scheduled task. The conversion mirrors the exact idiom used in previously merged ULP migrations authored by the PR author (e.g. #14302, #14472), and the ULP bound was measured empirically against the existing Julia fixtures for the JavaScript implementation.


@stdlib-js/reviewers


Generated by Claude Code

Replaces the relative-tolerance assertions in the `stats/base/dists/poisson/mgf`
test files with ULP-based assertions using
`@stdlib/assert/is-almost-same-value`. The measured maximum ULP difference
over the full Julia fixture set is 0, so the assertions use a bound of 0 ULP.

Ref: #11352

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

Copy link
Copy Markdown
Contributor

Coverage Report

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