Skip to content

test: migrate stats/base/dists/t/variance to ULP-based assertions - #16020

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-t-variance
Oct 11, 2026
Merged

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

Conversation

@kgryte

@kgryte kgryte commented Oct 9, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

Only test/test.native.js contained the computed-tolerance idiom (delta = abs( y - expected[ i ] ) / tol = 2.0 * EPS * abs( expected[ i ] )), so that is the only file changed. The fixture loop in test/test.js already used exact assertions, and, per the guidance in #11352 to avoid extraneous test changes, it has been left as is.

Final ULP constant: 0.

The bound was measured rather than guessed. For every one of the 50 fixture cases, the smallest maxULP satisfying isAlmostSameValue( y, expected[ i ], maxULP ) was computed for both the JavaScript and the C implementation; the maximum over the fixture set is 0 in both cases. In other words, both implementations reproduce the Julia fixtures bit-for-bit, so 0 is the tightest admissible bound and no padding was added. This is consistent with test/test.js, which already asserted exact equality, and it means the old else branch was in practice unreachable on this fixture set.

A 0 ULP bound is well-established in the codebase for this situation; for example, stats/base/dists/beta/mean and stats/base/dists/beta/skewness use isAlmostSameValue( y, expected[ i ], 0 ) in their fixture loops.

Verification

  • The native add-on was built locally (make install-node-addons NODE_ADDONS_PATTERN="stats/base/dists/t/variance"), so the test.native.js assertions actually execute rather than being skipped: test/test.js reports 58 passing and test/test.native.js reports 59 passing.
  • make test TESTS_FILTER=".*/stats/base/dists/t/variance/.*" was run twice at the final bound, with identical results both times (no arch/FMA-dependent variation).
  • eslint is clean against etc/eslint/.eslintrc.tests.js, and lint-license-headers-files passes.
  • The only file changed is test/test.native.js.

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?

One, on a judgment call: since the measured minimum is 0 and test/test.js was already exact, an alternative reading is that this package has no tolerance to migrate and should be skipped entirely. This PR instead removes the dead tolerance branch and states the 0 ULP budget explicitly, matching the beta/mean precedent. Happy to close this if you would rather leave such packages untouched.

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 by Claude Code running as an unattended scheduled task. It selected the package, mirrored the conversion idiom from already-merged PRs in the same family, measured the ULP bound programmatically over the full fixture set, and ran the tests and linters locally. The changes have not been reviewed by a human prior to submission, which is why it is opened as a draft.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01JJ2JUhP1NnZRW3mrjB7UpH


Generated by Claude Code

Replaces the computed relative tolerance comparison in the native test
fixture loop with a ULP-based assertion. The measured minimum required
ULP difference over the full fixture set is zero for both the JavaScript
and C implementations, which is consistent with the exact assertions
already used in `test/test.js`.

Ref: #11352

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/t/variance $\\color{green}169/169$
$\\color{green}+100.00\\%$
$\\color{green}10/10$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}169/169$
$\\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 11, 2026
@kgryte
kgryte marked this pull request as ready for review October 11, 2026 12:36
@kgryte
kgryte requested a review from a team October 11, 2026 12:36
@kgryte
kgryte merged commit 8c87ef1 into develop Oct 11, 2026
66 checks passed
@kgryte
kgryte deleted the kgryte/ulp-t-variance branch October 11, 2026 12:36
@stdlib-bot stdlib-bot added Needs Review A pull request which needs code review. and removed Needs Review A pull request which needs code review. labels Oct 11, 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.

2 participants