From 63b983914a379c12ada4e0654322d32470bfa236 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 26 Sep 2026 09:16:53 +0000 Subject: [PATCH] test: migrate `stats/incr/mhmean` to ULP-based assertions Resolves a part of #11352 Replaces relative-tolerance comparisons (`EPS * abs(...)`) in the package's test suite with `isAlmostSameValue` ULP-difference assertions, tightened to the minimum ULP required for each case. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_012mhq6GePBcsMEYEDQh3R1Y --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: skipped - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/stats/incr/mhmean/test/test.js | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/mhmean/test/test.js b/lib/node_modules/@stdlib/stats/incr/mhmean/test/test.js index 338377e7ad5d..33cc8c7c3ae3 100644 --- a/lib/node_modules/@stdlib/stats/incr/mhmean/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/mhmean/test/test.js @@ -22,8 +22,7 @@ var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var EPSILON = require( '@stdlib/constants/float64/eps' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var incrmhmean = require( './../lib' ); @@ -73,9 +72,7 @@ tape( 'the function returns an accumulator function', function test( t ) { tape( 'the accumulator function computes a moving harmonic mean incrementally', function test( t ) { var expected; var actual; - var delta; var data; - var tol; var acc; var N; var i; @@ -100,13 +97,7 @@ tape( 'the accumulator function computes a moving harmonic mean incrementally', ]; for ( i = 0; i < N; i++ ) { - if ( actual[ i ] === expected[ i ] ) { - t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); - } else { - delta = abs( expected[ i ] - actual[ i ] ); - tol = EPSILON * abs( expected[ i ] ); - t.strictEqual( delta <= tol, true, 'within tolerance. Expected: '+expected[ i ]+'. Actual: '+actual[ i ]+'. Delta: '+delta+'. Tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( actual[ i ], expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); @@ -114,10 +105,8 @@ tape( 'the accumulator function computes a moving harmonic mean incrementally', tape( 'if not provided an input value, the accumulator function returns the current harmonic mean', function test( t ) { var expected; var actual; - var delta; var data; var acc; - var tol; var i; data = [ 2.0, 3.0, 5.0 ]; @@ -127,9 +116,7 @@ tape( 'if not provided an input value, the accumulator function returns the curr } actual = acc(); expected = 3.75; // Note: computed by hand using textbook formula - delta = abs( expected - actual ); - tol = 1.1 * EPSILON * abs( expected ); - t.strictEqual( delta <= tol, true, 'within tolerance. Expected: '+expected+'. Actual: '+actual+'. Delta: '+delta+'. Tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( actual, expected, 2 ), true, 'returns expected value' ); t.end(); });