Skip to content

test: migrate stats/chi2test to ULP-based assertions - #15346

Draft
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-chi2test
Draft

kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-chi2test

Conversation

@kgryte

@kgryte kgryte commented Sep 19, 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/chi2test from relative tolerance testing (delta <= tol, where tol = N * EPS * abs( expected )) to ULP difference testing using @stdlib/assert/is-almost-same-value.
  • removes the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires.

Each assertion uses the measured minimum ULP value which still passes. Bounds were found by scanning upward from 0 for every assertion and then confirming that N-1 fails:

Test case pValue statistic
two-way contingency table 1 2
two-way contingency table (ndarray) 1 2
two categories each (with continuity correction) 16 0
two categories each (without continuity correction) 8 0
more columns than rows 2 0
more rows than columns 0 0

The package has no test/test.native.js, so test/test.js is the only test file changed.

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.

Verification performed locally:

  • make test TESTS_FILTER=".*/stats/chi2test/.*" → 72 passing, 0 failing. Run twice at the final ULP values to confirm determinism.
  • make eslint-tests TESTS_FILTER=".*/stats/chi2test/.*" → clean.

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, human-configured routine which converts one package per run. The ULP bounds were measured programmatically against the existing R fixtures rather than guessed.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_0123sP14BeF6ekQw7pe3qbWB


Generated by Claude Code

Replace relative tolerance comparisons with `isAlmostSameValue` ULP
difference assertions, using the minimum required ULP value for each
test case.

Ref: #11352

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/chi2test $\\color{red}859/878$
$\\color{green}+97.84\\%$
$\\color{red}67/71$
$\\color{green}+94.37\\%$
$\\color{red}14/18$
$\\color{green}+77.78\\%$
$\\color{red}859/878$
$\\color{green}+97.84\\%$

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 to ULP-based testing (its own instructions say to search for a package "in math/base/special"). This PR migrates tests for stats/chi2test, which is outside the issue'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

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