FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test: migrate `stats/base/dists/triangular/variance` to ULP-based assertions by kgryte · Pull Request #14425 · stdlib-js/stdlib · GitHub

test: migrate stats/base/dists/triangular/variance to ULP-based assertions - #14425

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-stats-base-dists-triangular-variance
Aug 20, 2026
Merged

test: migrate stats/base/dists/triangular/variance to ULP-based assertions#14425
kgryte merged 1 commit into
developfrom
kgryte/ulp-stats-base-dists-triangular-variance

Conversation

kgryte commented Aug 19, 2026

Copy link
Copy Markdown
Member

Ref #11352.

Description

What is the purpose of this pull request?

This pull request:

  • migrates the tests for stats/base/dists/triangular/variance from computed floating-point tolerances to ULP-based assertions, per [RFC]: Migrate math/base/special packages from relative tolerance testing to ULP difference testing (tracking issue) #11352.
  • replaces the delta/tol (EPS * abs( expected[i] )) comparison in test/test.js with isAlmostSameValue( y, expected[ i ], 0 ).
  • replaces the toFixed( 4 ) string comparison and delta/tol fallback in test/test.native.js with isAlmostSameValue( y, expected[ i ], 0 ).
  • adds the @stdlib/assert/is-almost-same-value require and drops the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires.

Final ULP bound: 0 in both test/test.js and test/test.native.js.

Measured minimum: starting from a high bound and tightening, the minimum integer bound which passes over the full fixture set is 0, i.e. both implementations reproduce every fixture value bit-for-bit. Over all 500 Julia fixture values, the maximum ULP difference is 0 for the JavaScript implementation and 0 for the native implementation (the native add-on was built locally so that test/test.native.js actually executed rather than being skipped). The full suite (1018 assertions across both test files) was run twice at the final bound with identical results, so no FMA/arch-related nondeterminism was observed on this platform (Linux x86-64, gcc).

This is expected: the JavaScript and C implementations evaluate the identical expression ( (a*a) + (b*b) + (c*c) - (a*b) - (a*c) - (b*c) ) / 18.0, so absent FMA contraction the two agree exactly with the reference values.

Only the two test files are modified; no source, documentation, benchmark, or fixture files are touched.

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?

  • A bound of 0 means isAlmostSameValue falls back to SameValue semantics (as is the case elsewhere in the repository, where 0 is already used in a number of converted packages). If reviewers would prefer to retain a single ULP of headroom in test/test.native.js to guard against FMA contraction on architectures where the C compiler fuses the multiply-adds (e.g. arm64), the native bound can be relaxed to 1. As measured on x86-64, 0 passes.

Other

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

  • Verification performed: package tests green (1018/1018 assertions passing, run twice), lint clean via make lint-javascript-files ESLINT_CONF=etc/eslint/.eslintrc.tests.js, and git status confirms only the two test files 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 PR was written primarily by Claude Code, which selected the package, mirrored the conversion idiom used in previously converted packages, measured the ULP bound against the fixture set, and verified tests and linting.


@stdlib-js/reviewers


Generated by Claude Code

…ertions

Replaces EPS-scaled relative tolerance comparisons (and, in the native
test, `toFixed( 4 )` string comparisons) with `isAlmostSameValue`
assertions. Over the full 500-value Julia fixture set, both the
JavaScript and native implementations reproduce the expected values
bit-for-bit, so the tightest passing bound is 0 ULP.

Ref: #11352

Claude-Session: https://claude.ai/code/session_01PjUefgKYy3gQjkssALyEzH
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 19, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/triangular/variance $\\color{green}197/197$
$\\color{green}+100.00\\%$
$\\color{green}11/11$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}197/197$
$\\color{green}+100.00\\%$

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 Issue #11352 is explicitly scoped to migrating math/base/special packages from relative-tolerance to ULP-based testing ("This RFC proposes migrating ... for math/base/special functions"), but this PR migrates tests for stats/base/dists/triangular/variance, which is outside that namespace.

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 added the Tests Pull requests specifically adding tests. label Aug 20, 2026
kgryte marked this pull request as ready for review August 20, 2026 01:52
kgryte requested a review from a team August 20, 2026 01:52
stdlib-bot added the Needs Review A pull request which needs code review. label Aug 20, 2026
kgryte merged commit e48a0d5 into develop Aug 20, 2026
82 checks passed
kgryte deleted the kgryte/ulp-stats-base-dists-triangular-variance branch August 20, 2026 01:53
stdlib-bot removed the Needs Review A pull request which needs code review. label Aug 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL