From 8d37c51cf0515e7e4d214f05e0a05a51ad78bfed Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 15 Oct 2026 02:24:13 +0000 Subject: [PATCH] test: migrate `stats/incr/nanmapcorr` to ULP-based assertions Migrate the tests for `stats/incr/nanmapcorr` from relative tolerance testing to ULP difference testing using `@stdlib/assert/is-almost-same-value`. Each ULP bound is tightened to the minimum integer which still passes over the full set of test cases. Additionally, switch the simulated datasets from the global PRNG seed (`randu.seed`) to a fixed seed (`123456`), as is required in order for a tightened ULP bound to be deterministic. This mirrors the already migrated `stats/incr/mapcorr`, which is the non-NaN analog of this package. Ref: https://github.com/stdlib-js/stdlib/issues/11352 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01M1KYLesBsrREWPeaXVwgZ2 --- .../stats/incr/nanmapcorr/test/test.js | 42 ++++--------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmapcorr/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmapcorr/test/test.js index 695c7c865fb0..26aa94e02386 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmapcorr/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmapcorr/test/test.js @@ -21,12 +21,12 @@ // MODULES // var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var randu = require( '@stdlib/random/base/randu' ); var abs = require( '@stdlib/math/base/special/abs' ); var pow = require( '@stdlib/math/base/special/pow' ); var sqrt = require( '@stdlib/math/base/special/sqrt' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var incrnanmapcorr = require( './../lib' ); @@ -330,12 +330,10 @@ tape( 'the accumulator function computes a moving sample absolute Pearson produc var validData; var expected; var actual; - var delta; var means; var prev; var data; var acc; - var tol; var d; var N; var M; @@ -347,7 +345,7 @@ tape( 'the accumulator function computes a moving sample absolute Pearson produc N = 10; M = 100; - data = datasets( N, M, randu.seed ); + data = datasets( N, M, 123456 ); // Define the window size: W = 10; @@ -377,12 +375,8 @@ tape( 'the accumulator function computes a moving sample absolute Pearson produc } if ( isnan( expected ) ) { t.equal( isnan( actual ), true, 'returns NaN for window: '+i ); - } else if ( actual === expected ) { - t.equal( actual, expected, 'returns expected value. dataset: '+i+'. window: '+j+'.' ); } else { - delta = abs( actual - expected ); - tol = 5.0e5 * EPS * abs( expected ); - t.equal( delta < tol, true, 'dataset: '+i+'. window: '+j+'. expected: '+expected+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' ); + t.strictEqual( isAlmostSameValue( actual, expected, 2457 ), true, 'returns expected value' ); } } } @@ -394,11 +388,9 @@ tape( 'the accumulator function computes a moving sample absolute Pearson produc var expected; var actual; var means; - var delta; var data; var prev; var acc; - var tol; var d; var N; var M; @@ -410,7 +402,7 @@ tape( 'the accumulator function computes a moving sample absolute Pearson produc N = 10; M = 100; - data = datasets( N, M, randu.seed ); + data = datasets( N, M, 123456 ); validData = []; for ( i = 0; i < N; i++ ) { d = data[ i ]; @@ -450,12 +442,8 @@ tape( 'the accumulator function computes a moving sample absolute Pearson produc } if ( isnan( expected ) ) { t.equal( isnan( actual ), true, 'dataset: '+i+', window: '+j+' returns NaN as expected' ); - } else if ( actual === expected ) { - t.equal( actual, expected, 'returns expected value. dataset: '+i+'. window: '+j+'.' ); } else { - delta = abs( actual - expected ); - tol = 5.0e5 * EPS * abs( expected ); - t.equal( delta < tol, true, 'dataset: '+i+'. window: '+j+'. expected: '+expected+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' ); + t.strictEqual( isAlmostSameValue( actual, expected, 0 ), true, 'returns expected value' ); } } } @@ -467,10 +455,8 @@ tape( 'if not provided an input value, the accumulator function returns the curr var expected; var actual; var means; - var delta; var prev; var data; - var tol; var acc; var W; var N; @@ -509,13 +495,7 @@ tape( 'if not provided an input value, the accumulator function returns the curr expected = apcorr( validData, means[ 0 ], means[ 1 ], false ); prev = expected; } - if ( actual === expected ) { - t.equal( actual, expected, 'returns expected value. window: '+i+'.' ); - } else { - delta = abs( actual - expected ); - tol = 2.0 * EPS * abs( expected ); - t.equal( delta < tol, true, 'window: '+i+'. expected: '+expected+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( actual, expected, 2 ), true, 'returns expected value' ); } t.end(); }); @@ -525,10 +505,8 @@ tape( 'if not provided an input value, the accumulator function returns the curr var expected; var actual; var means; - var delta; var prev; var data; - var tol; var acc; var W; var N; @@ -575,13 +553,7 @@ tape( 'if not provided an input value, the accumulator function returns the curr expected = apcorr( validData, means[ 0 ], means[ 1 ], true ); prev = expected; } - if ( actual === expected ) { - t.equal( actual, expected, 'returns expected value. window: '+i+'.' ); - } else { - delta = abs( actual - expected ); - tol = 2.0 * EPS * abs( expected ); - t.equal( delta < tol, true, 'window: '+i+'. expected: '+expected+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( actual, expected, 0 ), true, 'returns expected value' ); } t.end(); });