Skip to content

test: migrate stats/base/dists/planck/variance to ULP-based assertions - #15794

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-planck-variance
Oct 2, 2026
Merged

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

Conversation

@kgryte

@kgryte kgryte commented Oct 2, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

  • Migrates unit tests for @stdlib/stats/base/dists/planck/variance from relative tolerance checks (delta <= tol) to ULP-based assertions using @stdlib/assert/is-almost-same-value.

The converted assertions use a bound of 1 ULP in both test/test.js and test/test.native.js:

t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );

1 ULP is the measured minimum. The bound was tightened empirically, starting from 64 and walking down over the full 1000-element Python fixture set (64, 32, 16, 8, 4, 2, 1 all pass; 0 fails 103 of the 1000 cases). Independently computing ulpDifference( y, expected[ i ] ) across the fixtures gives a maximum of 1, attained at lambda = 13.503035075315534. The suite was run twice at the final bound to confirm determinism (no FMA/arch variability); both runs reported 1005/1005 passing.

Only the two test files are changed; no source, documentation, or fixture files were touched. The native tests skip in this environment, as the C addon is not built locally, so the 1 ULP bound for test.native.js mirrors the JavaScript result and the convention already established by the converted sibling packages (planck/mean, planck/stdev, planck/cdf).

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.

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

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 entirely by Claude Code, running unattended as a scheduled task. Claude selected the package, studied the idiom used by already-converted sibling packages, performed the conversion, and determined the minimum ULP bound empirically.


@stdlib-js/reviewers


Generated by Claude Code

Migrates unit tests from relative tolerance checks (`delta <= tol`) to
ULP-based assertions using `@stdlib/assert/is-almost-same-value`.

The measured maximum ULP difference over the 1000-element Python fixture
set is 1, so the assertions use a bound of 1 ULP, which is the tightest
integer bound which passes (a bound of 0 fails 103 of the 1000 cases).

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/planck/variance $\\color{green}165/165$
$\\color{green}+100.00\\%$
$\\color{green}8/8$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}165/165$
$\\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 2, 2026
@kgryte
kgryte marked this pull request as ready for review October 2, 2026 07:22
@kgryte
kgryte requested a review from a team October 2, 2026 07:22
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Oct 2, 2026
@kgryte
kgryte merged commit e9f509b into develop Oct 2, 2026
82 checks passed
@kgryte
kgryte deleted the kgryte/ulp-planck-variance branch October 2, 2026 07:23
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Oct 2, 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