Skip to content

test: migrate stats/base/dists/pareto-type1/pdf to ULP-based assertions - #14902

Merged
kgryte merged 1 commit into
developfrom
claude/great-brahmagupta-tqg0d2
Sep 3, 2026
Merged

kgryte merged 1 commit into
developfrom
claude/great-brahmagupta-tqg0d2

Conversation

@kgryte

@kgryte kgryte commented Sep 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 the tests for stats/base/dists/pareto-type1/pdf from relative tolerance assertions 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 computations (previously 40.0 * EPS * abs( expected[ i ] ) and 20.0 * EPS * abs( expected[ i ] )) in test/test.pdf.js, test/test.factory.js, and test/test.native.js with t.strictEqual( isAlmostSameValue( y, expected[ i ], N ), true, 'returns expected value' );.
  • 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.

Only the three test files are changed; the implementation, fixtures, and documentation are untouched. test/test.js is unchanged, as it contains no tolerance-based assertions.

Measured ULP bounds (identical in all three test files, one per fixture set):

Fixture ULP bound
fixtures/julia/both_large.json 45
fixtures/julia/large_alpha.json 54
fixtures/julia/large_beta.json 29

Each bound was tightened by measuring the ULP difference between the returned value and the expected value across the full fixture set (1000 cases per fixture). Starting from a loose bound of 64 and lowering it, the values above are the minimum integers at which each fixture set passes: the maximum observed ULP differences are exactly 45, 54, and 29, and re-running at 44, 53, and 28 respectively fails. The same maxima were measured independently for the JavaScript implementation, for the function returned by factory, and for the compiled C add-on, so a single set of values applies to all three test files.

Verification performed:

  • test/test.pdf.js: 3022/3022 assertions passing.
  • test/test.factory.js: 3025/3025 assertions passing.
  • test/test.native.js: 3022/3022 assertions passing against the compiled native add-on (built locally so the native suite actually executed rather than being skipped).
  • test/test.js: 3/3 assertions passing (unchanged).
  • All suites were run twice at the final bounds with identical results, confirming the bounds are not sensitive to FMA/architecture variation.
  • ESLint clean against etc/eslint/.eslintrc.tests.js for all three files.

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.

The JavaScript and C implementations evaluate the same closed-form Pareto (Type I) density expression using stdlib's own pow, and the maximum deviation from the Julia reference fixtures is identical for both, so the same ULP values apply to test.pdf.js, test.factory.js, and test.native.js alike. The previous relative tolerances (40 * EPS ≈ 180 ULP and 20 * EPS ≈ 90 ULP) were looser than the measured bounds, so the migration tightens the accuracy budget for every fixture set.

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 authored by Claude Code as part of an automated batch migration of tolerance-based tests to ULP-based assertions. The ULP bounds were determined empirically by measuring ULP differences across the full fixture sets and confirming the test suites pass deterministically at the minimum values.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01S7nbhyRgHU7XRP4odpVTw6


Generated by Claude Code

…ions

Ref: #11352

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S7nbhyRgHU7XRP4odpVTw6

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/pareto-type1/pdf $\\color{red}336/339$
$\\color{green}+99.11\\%$
$\\color{green}24/24$
$\\color{green}+100.00\\%$
$\\color{red}3/4$
$\\color{green}+75.00\\%$
$\\color{red}336/339$
$\\color{green}+99.11\\%$

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 an RFC explicitly scoped to migrating math/base/special packages from relative-tolerance testing to ULP-difference testing, but this PR modifies tests in stats/base/dists/pareto-type1/pdf, a different package tree not covered by that RFC's stated scope.

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 kgryte added the Tests Pull requests specifically adding tests. label Sep 3, 2026
@kgryte
kgryte marked this pull request as ready for review September 3, 2026 03:19
@kgryte
kgryte requested a review from a team September 3, 2026 03:19
@kgryte
kgryte merged commit 112d4c3 into develop Sep 3, 2026
66 checks passed
@kgryte
kgryte deleted the claude/great-brahmagupta-tqg0d2 branch September 3, 2026 03:20
@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 Sep 3, 2026
@kgryte kgryte removed the Needs Review A pull request which needs code review. label Sep 5, 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.

4 participants