Skip to content

test: migrate stats/strided/dsemtk to ULP-based assertions - #15619

Merged
kgryte merged 1 commit into
developfrom
philipp/ulp-stats-strided-dsemtk
Sep 28, 2026
Merged

kgryte merged 1 commit into
developfrom
philipp/ulp-stats-strided-dsemtk

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

  • Migrates the test suite for stats/strided/dsemtk from relative-tolerance (EPS-based) floating-point comparisons to ULP-difference based assertions using @stdlib/assert/is-almost-same-value, per the tracking issue [RFC]: Migrate math/base/special packages from relative tolerance testing to ULP difference testing (tracking issue) #11352.
  • Converts all four test files for the package: test/test.dsemtk.js, test/test.dsemtk.native.js, test/test.ndarray.js, and test/test.ndarray.native.js. Each file had two floating-point comparisons using the old delta <= tol idiom (tol = 1.0 * EPS * abs( expected )), which are now t.strictEqual( isAlmostSameValue( v, expected, 1 ), true, 'returns expected value' ).
  • Removes the now-unused abs and EPS requires (and the delta/tol local variable declarations) from each test file.
  • The minimum ULP tolerance was determined empirically: starting from a high value and lowering it, ULP=0 fails for both floating-point assertions, while ULP=1 passes all cases. The full package test suite was run twice at ULP=1 to confirm deterministic (non-flaky) results.
  • No other test cases (exact t.strictEqual/isnan checks) were touched, consistent with the migration guidance in [RFC]: Migrate math/base/special packages from relative tolerance testing to ULP difference testing (tracking issue) #11352.

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.

Final ULP constant: 1 (measured minimum; 0 fails, 1 passes deterministically across repeated runs). No named ULP constant was introduced, matching the pattern already used in this package family's converted tests (e.g. stats/strided/dsem, stats/strided/dsempn), which pass the literal ULP value directly to isAlmostSameValue.

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, which studied prior-art conversions in the same package family (stats/strided/dsem, stats/strided/dsempn) and the tracking issue #11352 before authoring the change, and empirically determined the minimum ULP tolerance by running the test suite.


@stdlib-js/reviewers


🤖 Generated with Claude Code

https://claude.ai/code/session_01GfhKkXU78VTa7ZEDFn21v7


Generated by Claude Code

Replaces the relative-tolerance (EPS-based) floating-point comparisons
in the test suite with `isAlmostSameValue` ULP-difference checks, per
the migration described in #11352.

The minimum ULP tolerance was determined empirically (starting at a
high value and lowering until failures occurred): ULP=0 fails, ULP=1
passes deterministically across repeated runs, so ULP=1 is used.

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/strided/dsemtk $\\color{green}350/350$
$\\color{green}+100.00\\%$
$\\color{green}13/13$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}350/350$
$\\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 28, 2026
@kgryte
kgryte marked this pull request as ready for review September 28, 2026 22:06
@kgryte
kgryte requested a review from a team September 28, 2026 22:06
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Sep 28, 2026
@kgryte
kgryte merged commit 795cbfe into develop Sep 28, 2026
82 checks passed
@kgryte
kgryte deleted the philipp/ulp-stats-strided-dsemtk branch September 28, 2026 22:07
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Sep 28, 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