Skip to content

test: migrate stats/chi2gof to ULP-based assertions - #15687

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-chi2gof
Sep 30, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-chi2gof

Conversation

@kgryte

@kgryte kgryte commented Sep 30, 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/chi2gof from relative tolerance assertions to ULP-based assertions using @stdlib/assert/is-almost-same-value, following the idiom established in the already-migrated sibling stats/chi2test.
  • removes the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires, along with the associated delta/tol declarations.
  • updates test/test.js only. No other test file in the package contains relative tolerance assertions, and the package has no native (*.native.js) tests.

ULP measurement

Each converted assertion was swept downward from a high bound to the minimum integer that still passes over the full fixture set:

Test Assertion Actual Expected Min. ULP
... (when y is array of probabilities) out.pValue 0.04059404334478123 0.0405940433447812 4
... (when y is array of probabilities) out.statistic 9.990143369175627 9.99014336917563 2
... (when y is array of expected counts) out.pValue 0.04059404334478123 0.0405940433447812 4
... (when y is array of expected counts) out.statistic 9.990143369175627 9.99014336917563 2

Accordingly, the final bounds are 4 ULP for pValue and 2 ULP for statistic. Lowering either bound by one (3 and 1, respectively) causes the corresponding assertions to fail, confirming these are the tightest bounds. The package test suite was run twice at the final bounds and produced identical, passing results, confirming determinism.

Test cases that already asserted exact equality via t.strictEqual were left untouched.

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 pending CI.

make eslint-tests TESTS_FILTER=".*/stats/chi2gof/.*" reports no errors (only two pre-existing FIXME warnings on untouched lines). The editorconfig-checker binary could not be downloaded in the environment used to author this change, so EditorConfig conformance (LF endings, tab indentation, no trailing whitespace, final newline) was verified manually instead.

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.

This PR was written by Claude Code running as an unattended scheduled task. The agent studied the already-migrated sibling package stats/chi2test to mirror the established idiom, applied the conversion, and determined the minimum ULP bounds empirically by sweeping bounds against the fixture values.


@stdlib-js/reviewers


Generated by Claude Code

Migrate the relative tolerance assertions in the `stats/chi2gof` test
suite to ULP-based assertions using `@stdlib/assert/is-almost-same-value`.

The ULP bounds are the measured minimums for the existing fixture
values: 4 ULP for `pValue` and 2 ULP for `statistic`.

Ref: #11352

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FrmMNwQtd5wpBrd7YKaLf
@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 30, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/chi2gof $\\color{red}955/983$
$\\color{green}+97.15\\%$
$\\color{red}103/114$
$\\color{green}+90.35\\%$
$\\color{red}13/15$
$\\color{green}+86.67\\%$
$\\color{red}955/983$
$\\color{green}+97.15\\%$

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

@kgryte kgryte added the Tests Pull requests specifically adding tests. label Sep 30, 2026
@kgryte
kgryte marked this pull request as ready for review September 30, 2026 19:15
@kgryte
kgryte requested a review from a team September 30, 2026 19:15
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Sep 30, 2026
@kgryte
kgryte merged commit 9966ca6 into develop Sep 30, 2026
82 checks passed
@kgryte
kgryte deleted the kgryte/ulp-chi2gof branch September 30, 2026 19:16
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Sep 30, 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