Skip to content

test: migrate stats/incr/hmean to ULP-based assertions - #16024

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-stats-incr-hmean
Oct 11, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-stats-incr-hmean

Conversation

@kgryte

@kgryte kgryte commented Oct 10, 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 @stdlib/stats/incr/hmean from relative tolerance testing to ULP difference testing.
  • replaces the abs/@stdlib/constants/float64/eps requires with @stdlib/assert/is-almost-same-value.
  • removes the delta/tol computation and the actual === expected branch in favor of a single t.strictEqual( isAlmostSameValue( actual, expected, 1 ), true, 'returns expected value' ); assertion.

The package has a single test file (test/test.js); there is no test/test.native.js.

Measured ULP bound: the maximum ULP difference across the test data ([ 2.0, 3.0, 2.0, 4.0, 3.0, 4.0 ]) is 1, arising from the final accumulated value (2.769230769230769 vs. 2.7692307692307696). All other iterations are bit-for-bit exact. Accordingly, the assertion uses a bound of 1, which is the minimum passing value: re-running the suite with 0 fails one assertion, while 1 passes all 11 assertions. The suite was run twice at the final bound to confirm determinism.

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.

  • Tests pass locally via make test TESTS_FILTER=".*/stats/incr/hmean/.*" (11/11).
  • Linting is clean via make lint-javascript-tests TESTS_FILTER=".*/stats/incr/hmean/.*".
  • Only lib/node_modules/@stdlib/stats/incr/hmean/test/test.js is modified.

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 running as an unattended scheduled task. It studied the prior ULP migrations in the same package family (e.g. stats/incr/nanhmean, stats/incr/mstdev) to mirror the established idiom, applied the test conversion, and determined the minimum passing ULP bound empirically by measuring per-iteration ULP differences and then verifying that 0 fails and 1 passes.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01VAFLtSGuZB4wkzEqGU9r1n


Generated by Claude Code

Replaces the relative tolerance assertion in the `stats/incr/hmean`
accumulator test with an ULP difference assertion using
`@stdlib/assert/is-almost-same-value`. The measured maximum ULP
difference over the test data is 1, which is the minimum bound which
passes (0 fails).

Ref: #11352

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/incr/hmean $\\color{green}142/142$
$\\color{green}+100.00\\%$
$\\color{green}8/8$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}142/142$
$\\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 Oct 11, 2026
@kgryte
kgryte marked this pull request as ready for review October 11, 2026 12:35
@kgryte
kgryte requested a review from a team October 11, 2026 12:35
@kgryte
kgryte merged commit d6455a2 into develop Oct 11, 2026
66 checks passed
@kgryte
kgryte deleted the kgryte/ulp-stats-incr-hmean branch October 11, 2026 12:35
@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 Oct 11, 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