From cb5d96d913924d624ded1bb56d0d64820e020a24 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 8 Oct 2026 22:24:32 +0000 Subject: [PATCH] test: migrate `stats/incr/nangmean` to ULP-based assertions Replaces relative tolerance comparisons in the test suite with `@stdlib/assert/is-almost-same-value` ULP difference assertions. ULP bounds were tightened to the measured minimum which still passes over the full set of test cases: - incremental geometric mean accumulation: 2 ULP - current geometric mean on recall: 1 ULP Lowering either bound by one causes a test failure, and the suite was run twice at the final bounds to confirm determinism. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01HwRj94hUX3dG7FRc2TVZoc --- .../@stdlib/stats/incr/nangmean/test/test.js | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nangmean/test/test.js b/lib/node_modules/@stdlib/stats/incr/nangmean/test/test.js index b4d942a1915b..2965b4243826 100644 --- a/lib/node_modules/@stdlib/stats/incr/nangmean/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nangmean/test/test.js @@ -21,12 +21,11 @@ // MODULES // var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var ln = require( '@stdlib/math/base/special/ln' ); var exp = require( '@stdlib/math/base/special/exp' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var EPSILON = require( '@stdlib/constants/float64/eps' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var incrnangmean = require( './../lib' ); @@ -47,10 +46,8 @@ tape( 'the function returns an accumulator function', function test( t ) { tape( 'the accumulator function incrementally computes a geometric mean', function test( t ) { var expected; var actual; - var delta; var data; var prod; - var tol; var acc; var N; var d; @@ -72,23 +69,15 @@ tape( 'the accumulator function incrementally computes a geometric mean', functi j += 1; } actual = acc( d ); - if ( actual === expected ) { - t.strictEqual( actual, expected, 'returns expected value. d: '+d+'.' ); - } else { - delta = abs( expected - actual ); - tol = 1.5 * EPSILON * abs( expected ); - t.strictEqual( delta <= tol, true, 'within tolerance. d: '+d+'. Expected: '+expected+'. Actual: '+actual+'. Delta: '+delta+'. Tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( actual, expected, 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'if not provided an input value, the accumulator function returns the current geometric mean', function test( t ) { var expected; - var delta; var data; var acc; - var tol; var i; data = [ 2.0, NaN, 3.0, 1.0 ]; @@ -98,10 +87,7 @@ tape( 'if not provided an input value, the accumulator function returns the curr acc( data[ i ] ); } expected = 1.8171205928321397; - delta = abs( expected - acc() ); - tol = EPSILON * abs( expected ); - - t.strictEqual( delta <= tol, true, 'within tolerance. Expected: '+expected+'. Actual: '+acc()+'. Delta: '+delta+'. Tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( acc(), expected, 1 ), true, 'returns expected value' ); t.end(); });