Skip to content

test: migrate stats/base/dists/triangular/pdf to ULP-based assertions - #16279

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-stats-base-dists-triangular-pdf
Oct 24, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-stats-base-dists-triangular-pdf

Conversation

@kgryte

@kgryte kgryte commented Oct 21, 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 relative tolerance test cases in stats/base/dists/triangular/pdf to ULP difference testing.

The only file in this package still using relative tolerance was test/test.factory.js; the sibling test/test.pdf.js and test/test.native.js had already been migrated, so this change brings test.factory.js in line with them.

Each of the three fixture loops (small, medium, and large range) previously used:

if ( y === expected[i] ) {
    t.strictEqual( y, expected[i], ... );
} else {
    delta = abs( y - expected[ i ] );
    tol = 1.0 * EPS * abs( expected[ i ] );
    t.ok( delta <= tol, 'within tolerance. ...' );
}

and now uses:

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

The now-unused abs and EPS requires, along with the delta and tol declarations, were removed, and @stdlib/assert/is-almost-same-value was added.

ULP constant: 0 (all three fixture loops).

This is the measured minimum. The maximum observed ULP difference between the returned and expected values was 0 across all 3000 fixture values (1000 each for small_range, medium_range, and large_range), for both the factory and the direct pdf code paths, so no non-zero ULP allowance is required. Note that isAlmostSameValue with a maxULP of 0 falls back to a SameValue comparison; none of the fixtures contain a zero or signed-zero expected value, so this is safe. The implementation performs only plain IEEE 754 multiplication, subtraction, and division, which are correctly rounded and not subject to FMA contraction in JavaScript, so the result is bit-reproducible.

The package's test suite was run twice at the final ULP value to confirm determinism (3027 passing assertions in test.factory.js each time, with no failures).

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?

The already-migrated sibling test/test.pdf.js asserts the same three fixture sets with a ULP value of 1, where 0 would also pass. This pull request uses the measured minimum of 0 for test.factory.js, per the guidance in #11352 to use the minimum required ULP value. Happy to use 1 instead if you would prefer consistency with test.pdf.js over the tightest bound.

Other

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

  • Only test files were changed; no implementation, documentation, or fixture changes.
  • make test TESTS_FILTER=".*/stats/base/dists/triangular/pdf/.*" passes. test/test.native.js reports 0 tests in this environment because the native add-on was not built; this is pre-existing and unrelated to this change.
  • make eslint-tests TESTS_FILTER=".*/stats/base/dists/triangular/pdf/.*" passes cleanly.
  • The lint-editorconfig-files check could not be run in this environment, as it downloads the editorconfig-checker binary from GitHub and network access to that repository was unavailable. The changed lines were verified manually to use tab indentation, LF line endings, no trailing whitespace, and a final newline.

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 pull request was authored by Claude Code, run as an automated task by @kgryte. The migration mirrors the already-migrated test/test.pdf.js in the same package, and the ULP bound was measured empirically against all 3000 fixture values rather than guessed.


@stdlib-js/reviewers


Generated by Claude Code

Migrate the remaining relative tolerance test cases in `test.factory.js`
to ULP difference testing, matching the already migrated `test.pdf.js`
and `test.native.js` in this package.

The measured maximum ULP difference across all three fixture sets
(small, medium, and large range; 3000 values) is zero, so the minimum
required ULP value is 0.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JXoRr3mZZKDUogNbuRfHXz

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: skipped
  - task: lint_markdown_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@kgryte kgryte added the Tests Pull requests specifically adding tests. label Oct 24, 2026
@kgryte
kgryte marked this pull request as ready for review October 24, 2026 03:00
@kgryte
kgryte requested a review from a team October 24, 2026 03:00
@kgryte
kgryte merged commit 10bc5c8 into develop Oct 24, 2026
33 of 37 checks passed
@kgryte
kgryte deleted the kgryte/ulp-stats-base-dists-triangular-pdf branch October 24, 2026 03:01
@stdlib-bot stdlib-bot added the Good First PR A pull request resolving a Good First Issue. label Oct 24, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Hello! 👋

We've noticed that you've been opening a number of PRs addressing good first issues. Thank you for your interest and enthusiasm!

Now that you've made a few contributions, we suggest no longer working on good first issues. Instead, we encourage you to prioritize cleaning up any PRs which have yet to be merged and then proceed to work on more involved tasks.

Not only does this ensure that other new contributors can work on things and get ramped up on all things stdlib, it also ensures that you can spend your time on more challenging problems. 🚀

For ideas for future PRs, feel free to search the codebase for TODOs and FIXMEs and be sure to check out other open issues on the issue tracker. Cheers!

@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Needs Review A pull request which needs code review. and removed Needs Review A pull request which needs code review. labels Oct 24, 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