Skip to content

test: migrate stats/base/dists/gumbel/stdev to ULP-based assertions - #14811

Draft
kgryte wants to merge 1 commit into
developfrom
claude/great-brahmagupta-0b0nh5
Draft

test: migrate stats/base/dists/gumbel/stdev to ULP-based assertions#14811
kgryte wants to merge 1 commit into
developfrom
claude/great-brahmagupta-0b0nh5

Conversation

@kgryte

@kgryte kgryte commented Aug 30, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

The computed-tolerance idiom (delta = abs( y - expected[i] ), tol = 1.0 * EPS * abs( expected[i] ), t.ok( delta <= tol, ... )) is replaced with isAlmostSameValue from @stdlib/assert/is-almost-same-value, and the now-unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires are dropped. The existing expected[i] !== null guard is preserved. Only test/test.js and test/test.native.js are changed.

Final ULP constant: 1 (both test/test.js and test/test.native.js).

This is the measured minimum. Before editing, the JavaScript and C implementations were both run against the full Julia fixture set (100 cases, no null entries) and the minimum passing ULP bound was computed for every individual case:

implementation cases max ULP difference minimum passing N
JavaScript (lib/main.js) 100 1 1
C (src/main.c, addon built locally) 100 1 1

Both implementations agree bit-for-bit with each other, which is expected from the sources: each computes PI_OVER_SQRT6 * beta — a single correctly rounded IEEE-754 double multiplication, with no addition for a compiler to contract into an FMA. There is therefore no JS-vs-C divergence of the kind described in the FAQ, and no architecture-dependent rounding to absorb.

1 is the tightest bound that passes. The worst case is mu = -3.3192170148182183, beta = 0.9006151006176755, where the returned 1.1550837443384099 is one ULP above the fixture value 1.1550837443384097. Running the suite at N = 0 fails 18 of the 100 fixture assertions, so the bound is not merely conservative and the assertions are non-vacuous.

The suite was run twice at N = 1 with the native addon built, and both test/test.js (110 assertions) and test/test.native.js (111 assertions) passed identically on both runs. test/test.native.js was confirmed to be actually executing rather than skipping.

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.

Opened as a draft.

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 running as an unattended scheduled task. It selected the package, studied prior converted packages in the same family to match the established idiom, measured the minimum passing ULP bound for every fixture case against both the JavaScript and C implementations, and applied the edits.


@stdlib-js/reviewers


Generated by Claude Code

Ref: #11352

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/gumbel/stdev $\\color{green}180/180$
$\\color{green}+100.00\\%$
$\\color{green}9/9$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}180/180$
$\\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 #11352 is a tracking issue scoped explicitly to migrating math/base/special packages from relative-tolerance to ULP-based testing (its instructions say "Search for a package in math/base/special..."). This PR migrates stats/base/dists/gumbel/stdev, which is outside that tracked 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

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.

4 participants