test: migrate stats/incr/mmeanabs2 to ULP-based assertions - #15171
Merged
Conversation
Migrate the tests for `stats/incr/mmeanabs2` from a computed relative tolerance comparison to a ULP difference assertion using `@stdlib/assert/is-almost-same-value`. The measured minimum ULP bound is 1. Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JhctBo3ZhP4kbZgXCWBZ7a
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves a part of #11352.
Description
This pull request:
stats/incr/mmeanabs2from a computed relative-tolerance comparison (delta = abs( expected - actual )/tol = 1.0 * EPS * abs( expected ), asserted viat.strictEqual( delta <= tol, ... )) to a ULP-difference assertion using@stdlib/assert/is-almost-same-value.test/test.js. The package has notest/test.native.js. The remaining assertions in the file are exact comparisons againstnull, thrownTypeErrors, function types,NaN, and the exactly representable values17.0and9.8596, which are correct as-is and are left unchanged.@stdlib/math/base/special/absand@stdlib/constants/float64/epsrequires, along with thedeltaandtolvariable declarations.if ( actual === expected[i] ) { ... } else { ... }branch in the moving-mean-of-squared-absolute-values test into a single ULP assertion, matching the migrated idiom.Only a test file is changed; no implementation, fixture, or documentation changes are included.
ULP bounds
1.0 * EPS * abs( expected )1This is the minimum integer bound
Nsuch thatisAlmostSameValue( actual, expected[ i ], N )holds at every element of the fixture. It was measured by starting from a high bound (64, which passes) and tightening, computing the per-element ULP distance directly outside the test harness and then confirming through the test suite: atN = 1the suite is 41/41 passing, and atN = 0three assertions fail (38/41), so no tighter bound exists.The per-element ULP differences are
0, 0, 0, 1, 1, 1. The first three expected values (4.0,6.5,17.0/3.0) are reproduced bit-for-bit, while the last three (29.0/3.0,29.0/3.0,41.0/3.0) differ by one ULP: the accumulator computes the window mean incrementally rather than as a single division, so it returns9.666666666666668where the literal expression29.0/3.0rounds to9.666666666666666. The original test anticipated this by branching onactual === expected[i]and falling back to a relative tolerance for the inexact cases.make test TESTS_FILTER=".*/stats/incr/mmeanabs2/.*"was run twice at the final bound with identical results: 41/41 passing on both runs, no failures, ruling out FMA/architecture-dependent flakiness on this platform.make eslint-tests TESTS_FILTER=".*/stats/incr/mmeanabs2/.*"is clean.Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
No.
Other
The resulting diff mirrors the already-merged migrations for the sibling accumulator packages
stats/incr/mmape(#15150),stats/incr/mda(#15142), andstats/incr/nanmrss(#15166), which share the same test structure.Two environment notes, neither of which affected verification:
make install-node-modulesinitially failed withETARGETfores-object-atoms@^1.1.2. The version does exist in the registry (published 2026-05-22); the local npm packument cache was stale and served a filtered view. Afternpm cache clean --force, the install completed and the full toolchain was available for this PR.pre-commithook'slint-editorconfig-filesstep could not run, because it downloads theeditorconfig-checkerbinary from a GitHub release that this environment cannot reach. The changed file was instead checked manually against.editorconfig: LF line endings, tab indentation, no trailing whitespace, and a final newline.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written primarily by Claude Code, running as an unattended scheduled task. It selected the package, studied previously migrated packages in the same family to match the established idiom, performed the migration, and determined the minimum passing ULP bound empirically at the assertion site.
@stdlib-js/reviewers
🤖 Generated with Claude Code
https://claude.ai/code/session_01JhctBo3ZhP4kbZgXCWBZ7a
Generated by Claude Code