Skip to content

test: migrate stats/base/dists/negative-binomial/variance to ULP-based assertions - #15954

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-negative-binomial-variance
Oct 12, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-negative-binomial-variance

Conversation

@kgryte

@kgryte kgryte commented Oct 7, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

Specifically, in test/test.native.js:

  • adds the @stdlib/assert/is-almost-same-value import and removes the now-unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps imports.
  • removes the delta/tol computation and the y === expected[ i ] / relative tolerance branch.
  • replaces t.strictEqual( ... ) / t.ok( delta <= tol, ... ) with t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' );.

Final ULP constant: 0.

The bound was tightened empirically, rather than assumed. Starting from a high bound and lowering it, the measured maximum ULP difference across the full 200-case Julia fixture set is 0 — the native (C) implementation reproduces every fixture value bit-for-bit, so 0 is both the measured minimum and the floor. The native test suite was run twice at the final bound to rule out FMA/architecture-dependent flakiness, passing 208/208 assertions both times with the native add-on compiled locally (so the tryRequire skip did not mask the assertions).

Note that test/test.js is intentionally left unchanged: it already asserts exact equality via t.strictEqual( y, expected[ i ], ... ) and contains no relative tolerance math, so there is nothing to migrate there.

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?

  • test/test.js was left as-is because it performs exact comparisons rather than relative tolerance comparisons. If the preference is for both test files to use the isAlmostSameValue idiom consistently (as in, e.g., stats/base/dists/beta/variance), I am happy to convert it as well.

Other

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

  • The only file changed is test/test.native.js.
  • Verification run locally: make test TESTS_FILTER=".*/stats/base/dists/negative-binomial/variance/.*" passes, and eslint with etc/eslint/.eslintrc.tests.js reports no problems.
  • The lint-editorconfig-files pre-commit step could not execute in this environment because its checker binary could not be downloaded; EditorConfig conformance (tabs, LF line endings, final newline, no trailing whitespace introduced) was verified manually instead.

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 as part of an automated, unattended pass over the packages tracked by #11352. The agent studied the migration idiom from already-converted packages in the same family (stats/base/dists/beta/variance, stats/base/dists/negative-binomial/stdev), applied the mechanical transformation, compiled the native add-on, and measured the minimum viable ULP bound against the fixture set rather than guessing it.


@stdlib-js/reviewers


Generated by Claude Code

…sed assertions

Migrate the native test suite from relative tolerance assertions to ULP
difference assertions via `@stdlib/assert/is-almost-same-value`.

Ref: #11352

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/negative-binomial/variance $\\color{green}189/189$
$\\color{green}+100.00\\%$
$\\color{green}11/11$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}189/189$
$\\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 12:47
@kgryte
kgryte requested a review from a team October 12, 2026 12:47
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Oct 12, 2026
@kgryte
kgryte merged commit 9222a42 into develop Oct 12, 2026
82 checks passed
@kgryte
kgryte deleted the kgryte/ulp-negative-binomial-variance branch October 12, 2026 12:47
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label 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