Skip to content

test: migrate stats/base/dists/triangular/logcdf to ULP-based assertions - #14868

Draft
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-triangular-logcdf
Draft

test: migrate stats/base/dists/triangular/logcdf to ULP-based assertions#14868
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-triangular-logcdf

Conversation

@kgryte

@kgryte kgryte commented Sep 1, 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/triangular/logcdf from relative tolerance assertions to ULP-based assertions using @stdlib/assert/is-almost-same-value.
  • replaces the if ( y === expected[i] ) { ... } else { delta/tol ... } branches in the fixture-driven test cases with t.strictEqual( isAlmostSameValue( y, expected[ i ], N ), true, 'returns expected value' );.
  • removes the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires, along with the delta and tol declarations.

The previous assertions used a 10.0 * EPS * abs( expected[ i ] ) relative tolerance. The ULP bounds below are the minimum values which pass over the full set of fixture values (1000 values per fixture) and are applied consistently in test/test.logcdf.js, test/test.factory.js, and test/test.native.js:

Fixture Test case ULP
small_range.json evaluates the logcdf for x given a small range b - a 6
medium_range.json evaluates the logcdf for x given a medium range b - a 0
large_range.json evaluates the logcdf for x given a large range b - a 11

Minimality was verified by lowering the bounds by one ULP and confirming test failures (65 and 1110 both fail; the medium range bound is already exact). The measured maximum ULP differences over each fixture are 6, 0, and 11, respectively, and are identical for the JavaScript and C implementations, so the same bounds are used in test/test.native.js.

The suite was run twice at the final bounds, with all assertions passing in both runs (make test TESTS_FILTER=".*/stats/base/dists/triangular/logcdf/.*"): 3012 (test.logcdf.js), 3022 (test.factory.js), 3 (test.js), and 3012 (test.native.js, run against a locally built add-on). Only test files are changed.

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 by Claude Code, which performed the test migration and empirically determined the minimum ULP bounds.


@stdlib-js/reviewers


Generated by Claude Code

@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 Sep 1, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/triangular/logcdf $\\color{green}356/356$
$\\color{green}+100.00\\%$
$\\color{green}36/36$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}356/356$
$\\color{green}+100.00\\%$

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

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants