From e4a77059b580d43335f4f10560387ee9b297daa8 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 09:15:03 +0000 Subject: [PATCH] test: migrate `stats/base/dists/geometric/mean` to ULP-based assertions Replaces the computed EPS-relative-error tolerance check in the fixture test with `isAlmostSameValue`, matching the convention used by other already-migrated packages. Ref: #11352 Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01M884J6fni5LbgXZg7q7zsQ --- 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 --- --- .../stats/base/dists/geometric/mean/test/test.js | 13 ++----------- .../base/dists/geometric/mean/test/test.native.js | 13 ++----------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/geometric/mean/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/geometric/mean/test/test.js index 40ff1024b38a..4addc7ec82ea 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/geometric/mean/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/geometric/mean/test/test.js @@ -21,11 +21,10 @@ // MODULES // var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var abs = require( '@stdlib/math/base/special/abs' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var mean = require( './../lib' ); @@ -68,8 +67,6 @@ tape( 'if provided a success probability `p` outside of `[0,1]`, the function re tape( 'the function returns the mean of a geometric distribution', function test( t ) { var expected; - var delta; - var tol; var i; var p; var y; @@ -78,13 +75,7 @@ tape( 'the function returns the mean of a geometric distribution', function test p = data.p; for ( i = 0; i < expected.length; i++ ) { y = mean( p[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'p: '+p[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 1.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. p: '+p[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/geometric/mean/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/geometric/mean/test/test.native.js index c6167fc84ce4..dcf373a416ac 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/geometric/mean/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/geometric/mean/test/test.native.js @@ -22,12 +22,11 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var tryRequire = require( '@stdlib/utils/try-require' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var abs = require( '@stdlib/math/base/special/abs' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); // VARIABLES // @@ -77,8 +76,6 @@ tape( 'if provided a success probability `p` outside of `[0,1]`, the function re tape( 'the function returns the mean of a geometric distribution', opts, function test( t ) { var expected; - var delta; - var tol; var i; var p; var y; @@ -87,13 +84,7 @@ tape( 'the function returns the mean of a geometric distribution', opts, functio p = data.p; for ( i = 0; i < expected.length; i++ ) { y = mean( p[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'p: '+p[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 1.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. p: '+p[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' ); } t.end(); });