Skip to content

test: migrate stats/base/dists/gumbel/pdf to ULP-based assertions - #14942

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-gumbel-pdf
Sep 4, 2026
Merged

test: migrate stats/base/dists/gumbel/pdf to ULP-based assertions#14942
kgryte merged 1 commit into
developfrom
kgryte/ulp-gumbel-pdf

Conversation

@kgryte

@kgryte kgryte commented Sep 3, 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/gumbel/pdf from relative tolerance testing (delta <= EPS * abs( expected )) to ULP difference testing using @stdlib/assert/is-almost-same-value.

The following test files were updated:

  • test/test.pdf.js
  • test/test.factory.js
  • test/test.native.js

In each file, the @stdlib/math/base/special/abs and @stdlib/constants/float64/eps imports were removed, the @stdlib/assert/is-almost-same-value import was added, and each if ( y === expected[i] ) { ... } else { ... } tolerance block was replaced with a single t.strictEqual( isAlmostSameValue( y, expected[ i ], N ), true, 'returns expected value' ); assertion. The pre-existing expected[i] !== null fixture guards were left intact.

ULP bounds

The ULP bound was tightened to the measured minimum over the full fixture set. For every fixture (positive_mean, negative_mean, large_variance) and for both the main and factory entry points, the maximum observed ULP difference is 1, so 1 ULP is used throughout:

Fixture Fixture size Measured minimum ULP
positive_mean 1000 1
negative_mean 1000 1
large_variance 1000 1

At 0 ULPs, 548 of the 3015 assertions in test/test.pdf.js and 548 of the 3018 assertions in test/test.factory.js fail, confirming that 1 is the tightest bound which still passes. The suite was run twice at the final bound with identical results.

test/test.native.js uses the same 1 ULP bound, matching the convention in previously migrated packages in this family (e.g., stats/base/dists/gumbel/cdf, stats/base/dists/pareto-type1/pdf). The C implementation in src/main.c is a direct transliteration of lib/main.js and delegates to the same exp routine.

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.

Only test files are changed; no implementation, documentation, or fixture files were touched.

Note on verification: in the environment used to author this PR, make install-node-modules could not complete (es-object-atoms@^1.1.2 is not resolvable from the registry), so the native add-on could not be built and test/test.native.js was skipped locally, as it is whenever the add-on is absent. The JavaScript test files were run directly (twice, green) and linted with the repository's own etc/eslint/.eslintrc.tests.js configuration via the pre-commit hook, which reported no issues.

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, which studied previously merged migrations in this family, applied the mechanical conversion, and measured the minimum ULP bound over the full fixture set.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01U5hkgpAq7yZHbDyNf71eS8


Generated by Claude Code

Ref: #11352

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

---
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 Good First PR A pull request resolving a Good First Issue. Statistics Issue or pull request related to statistical functionality. labels Sep 3, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/gumbel/pdf $\\color{green}294/294$
$\\color{green}+100.00\\%$
$\\color{green}23/23$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}294/294$
$\\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 Sep 4, 2026
@kgryte
kgryte marked this pull request as ready for review September 4, 2026 02:04
@kgryte
kgryte requested a review from a team September 4, 2026 02:04
@kgryte
kgryte merged commit 2368233 into develop Sep 4, 2026
66 checks passed
@kgryte
kgryte deleted the kgryte/ulp-gumbel-pdf branch September 4, 2026 02:05
@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 4, 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