Skip to content

test: migrate stats/base/dists/negative-binomial/logpmf to ULP-based assertions - #14199

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-negative-binomial-logpmf
Aug 12, 2026
Merged

test: migrate stats/base/dists/negative-binomial/logpmf to ULP-based assertions#14199
kgryte merged 1 commit into
developfrom
kgryte/ulp-negative-binomial-logpmf

Conversation

@kgryte

@kgryte kgryte commented Aug 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/negative-binomial/logpmf from relative tolerance testing to ULP difference testing, replacing the computed delta/tol comparisons with @stdlib/assert/is-almost-same-value.
  • removes the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires and the associated delta/tol local variables.
  • applies the same changes to both test/test.factory.js and test/test.logpmf.js (test/test.js only asserts exports and required no changes).

The ULP bounds were tightened to the minimum value which still passes over the full fixture sets (each fixture set contains 1000 values, and the factory and main entry points require identical bounds):

Fixture set Assertion Previous tolerance Final ULP Measured minimum
small_small.json small r and p 10.0 * EPS * abs( expected ) 6 6 (fails at 5; worst case x = 13, r = 9, p = 0.135318550619653)
small_high.json small r, large p 40.0 * EPS * abs( expected ) 57 57 (fails at 56; worst case x = 0, r = 8, p = 0.9868792801820985)
high_small.json large r, small p 10.0 * EPS * abs( expected ) 9 9 (fails at 8; worst case x = 39, r = 14, p = 0.12604764008592798)
high_high.json large r and p 80.0 * EPS * abs( expected ) 109 109 (fails at 108; worst case x = 1, r = 93, p = 0.8327586644536866)

The larger bounds correspond to fixtures whose expected values are log-probabilities close to zero, where the relative tolerance expressed in ULPs is necessarily looser.

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/negative-binomial/logpmf/.*" passes: 4026 assertions in test/test.factory.js, 4020 in test/test.logpmf.js, and 3 in test/test.js, with no failures. The suite was run twice at the final ULP values with identical results, in order to rule out FMA/architecture-dependent flakiness.
  • Tightness was confirmed by re-evaluating every fixture set at N-1 ULP; each set fails at N-1, so none of the four bounds can be lowered further.
  • make lint-javascript-tests TESTS_FILTER=".*/stats/base/dists/negative-binomial/logpmf/.*" is clean.
  • The package has no native implementation, so there is no test/test.native.js to update.
  • Only the two test files are changed.

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. The conversion mirrors the idiom established in previously merged migration commits, and the ULP bounds were determined empirically rather than guessed.


@stdlib-js/reviewers


Generated by Claude Code

…d assertions

Ref: #11352

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/negative-binomial/logpmf $\\color{red}523/566$
$\\color{green}+92.40\\%$
$\\color{red}45/51$
$\\color{green}+88.24\\%$
$\\color{green}5/5$
$\\color{green}+100.00\\%$
$\\color{red}523/566$
$\\color{green}+92.40\\%$

The above coverage report was generated for the changes in this PR.

Copy link
Copy Markdown
Member

⚠️ Issue Reference Review

An automated check found potentially unrelated issue/PR references in this PR:

Reference Assessment Reasoning
#11352 suspicious #11352 is an RFC/tracking issue explicitly scoped to migrating math/base/special packages from relative-tolerance to ULP-based testing (its own instructions repeatedly say "a package in math/base/special" and "please only update the tests for a single package" within that namespace). This PR instead migrates tests for stats/base/dists/negative-binomial/logpmf, which falls outside the issue's stated scope, even though it applies the same general ULP-testing technique.

Why this matters: GitHub automatically closes issues referenced with
closing keywords (Resolves, Closes, Fixes) when the PR is merged. Incorrect
references can accidentally close unrelated issues.

What to do:

  • If the reference is correct, no action needed. This check may produce
    false positives.
  • If the reference is incorrect, please update your PR description.

This assessment was generated by an AI model and is informational only.


Generated by Claude Code

@kgryte kgryte added the Tests Pull requests specifically adding tests. label Aug 12, 2026
@kgryte
kgryte marked this pull request as ready for review August 12, 2026 23:03
@kgryte
kgryte requested a review from a team August 12, 2026 23:03
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 12, 2026
@kgryte
kgryte merged commit 7c88159 into develop Aug 12, 2026
82 checks passed
@kgryte
kgryte deleted the kgryte/ulp-negative-binomial-logpmf branch August 12, 2026 23:04
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Aug 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.

4 participants