From 9d1c47dd1850d15ffab78c3de77ffa84bc1ea8cd Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 21 Oct 2026 14:16:46 +0000 Subject: [PATCH] test: migrate `stats/incr/nanrss` to ULP-based assertions Replace the hand-rolled ULP tolerance check in the `stats/incr/nanrss` unit tests with `@stdlib/assert/is-almost-same-value`, mirroring the idiom already used in `stats/incr/rss`. Ref: https://github.com/stdlib-js/stdlib/issues/11352 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Qgtt3BxHNqCDE6TW4DgEeV --- .../@stdlib/stats/incr/nanrss/test/test.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanrss/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanrss/test/test.js index e8374337d657..07853bcff7f9 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanrss/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanrss/test/test.js @@ -21,7 +21,7 @@ // MODULES // var tape = require( 'tape' ); -var ulpdiff = require( '@stdlib/number/float64/base/ulp-difference' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var incrnanrss = require( './../lib' ); @@ -47,7 +47,6 @@ tape( 'the initial accumulated value is `null`', function test( t ) { tape( 'the accumulator function incrementally computes the residual sum of squares', function test( t ) { var expected; var actual; - var diff; var data; var acc; var sum; @@ -77,12 +76,7 @@ tape( 'the accumulator function incrementally computes the residual sum of squar sum += r * r; expected = sum; actual = acc( x, y ); - if ( actual === expected ) { - t.strictEqual( actual, expected, 'returns expected value' ); - } else { - diff = ulpdiff( actual, expected ); - t.strictEqual( diff <= 1, true, 'within 1 ulp. Actual: '+actual+'. Expected: '+expected+'. ULP diff: '+diff ); - } + t.strictEqual( isAlmostSameValue( actual, expected, 0 ), true, 'returns expected value' ); } t.end(); }); @@ -90,7 +84,6 @@ tape( 'the accumulator function incrementally computes the residual sum of squar tape( 'if not provided an input value, the accumulator function returns the current residual sum of squares', function test( t ) { var expected; var actual; - var diff; var data; var acc; var i; @@ -106,8 +99,7 @@ tape( 'if not provided an input value, the accumulator function returns the curr } actual = acc(); expected = 1.0 + 64.0 + 81.0; - diff = ulpdiff( actual, expected ); - t.strictEqual( diff <= 1, true, 'within 1 ulp. Actual: '+actual+'. Expected: '+expected+'. ULP diff: '+diff ); + t.strictEqual( isAlmostSameValue( actual, expected, 0 ), true, 'returns expected value' ); t.end(); });