diff --git a/lib/node_modules/@stdlib/stats/incr/mapcorr/test/test.js b/lib/node_modules/@stdlib/stats/incr/mapcorr/test/test.js index 118da31bfa13..1f3665805e63 100644 --- a/lib/node_modules/@stdlib/stats/incr/mapcorr/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/mapcorr/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 zeros = require( '@stdlib/array/base/zeros' ); var incrmapcorr = require( './../lib' ); @@ -329,12 +329,10 @@ tape( 'the function returns an accumulator function (known means)', function tes tape( 'the accumulator function computes a moving sample absolute Pearson product-moment correlation coefficient incrementally', function test( t ) { var expected; var actual; - var delta; var means; var data; var acc; var arr; - var tol; var d; var N; var M; @@ -344,7 +342,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; @@ -363,13 +361,7 @@ tape( 'the accumulator function computes a moving sample absolute Pearson produc } means = mean( [ 0.0, 0.0 ], arr ); expected = apcorr( arr, means[ 0 ], means[ 1 ], false ); - if ( actual === expected ) { - t.strictEqual( actual, expected, 'returns expected value. dataset: '+i+'. window: '+j+'.' ); - } else { - delta = abs( actual - expected ); - tol = 5.0e5 * EPS * abs( expected ); - t.strictEqual( delta < tol, true, 'dataset: '+i+'. window: '+j+'. expected: '+expected+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( actual, expected, 6716 ), true, 'returns expected value' ); } } t.end(); @@ -379,11 +371,9 @@ tape( 'the accumulator function computes a moving sample absolute Pearson produc var expected; var actual; var means; - var delta; var data; var acc; var arr; - var tol; var d; var N; var M; @@ -393,7 +383,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; @@ -411,13 +401,7 @@ tape( 'the accumulator function computes a moving sample absolute Pearson produc arr = d.slice( j-W+1, j+1 ); } expected = apcorr( arr, means[ 0 ], means[ 1 ], true ); - if ( actual === expected ) { - t.strictEqual( actual, expected, 'returns expected value. dataset: '+i+'. window: '+j+'.' ); - } else { - delta = abs( actual - expected ); - tol = 5.0e5 * EPS * abs( expected ); - t.strictEqual( delta < tol, true, 'dataset: '+i+'. window: '+j+'. expected: '+expected+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( actual, expected, 1623 ), true, 'returns expected value' ); } } t.end(); @@ -427,9 +411,7 @@ tape( 'if not provided an input value, the accumulator function returns the curr var expected; var actual; var means; - var delta; var data; - var tol; var acc; var W; var N; @@ -458,13 +440,7 @@ tape( 'if not provided an input value, the accumulator function returns the curr } means = mean( [ 0.0, 0.0 ], d ); expected = apcorr( d, means[ 0 ], means[ 1 ], false ); - if ( actual === expected ) { - t.strictEqual( actual, expected, 'returns expected value. window: '+i+'.' ); - } else { - delta = abs( actual - expected ); - tol = 1.0 * EPS * abs( expected ); - t.strictEqual( delta < tol, true, 'window: '+i+'. expected: '+expected+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( actual, expected, 1 ), true, 'returns expected value' ); } t.end(); }); @@ -473,9 +449,7 @@ tape( 'if not provided an input value, the accumulator function returns the curr var expected; var actual; var means; - var delta; var data; - var tol; var acc; var W; var N; @@ -504,13 +478,7 @@ tape( 'if not provided an input value, the accumulator function returns the curr d = data.slice( i-W+1, i+1 ); } expected = apcorr( d, means[ 0 ], means[ 1 ], true ); - if ( actual === expected ) { - t.strictEqual( actual, expected, 'returns expected value. window: '+i+'.' ); - } else { - delta = abs( actual - expected ); - tol = 1.0 * EPS * abs( expected ); - t.strictEqual( 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(); }); @@ -569,10 +537,8 @@ tape( 'if the window size is `1` and the means are known, the accumulator functi tape( 'if provided `NaN`, the accumulated value is `NaN` for at least `W` invocations (unknown means)', function test( t ) { var expected; - var delta; var data; var acc; - var tol; var v; var i; @@ -631,12 +597,8 @@ tape( 'if provided `NaN`, the accumulated value is `NaN` for at least `W` invoca if ( isnan( expected[ i ] ) ) { t.strictEqual( isnan( v ), true, 'returns expected value for window '+i ); t.strictEqual( isnan( acc() ), true, 'returns expected value for window '+i ); - } else if ( v === expected[ i ] ) { - t.strictEqual( v, expected[ i ], 'returns expected value for window: '+i ); } else { - delta = abs( v - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.strictEqual( delta < tol, true, 'window: '+i+'. expected: '+expected[ i ]+'. actual: '+v+'. tol: '+tol+'. delta: '+delta+'.' ); + t.strictEqual( isAlmostSameValue( v, expected[ i ], 1 ), true, 'returns expected value' ); t.strictEqual( acc(), v, 'returns expected value for window '+i ); } } @@ -672,12 +634,8 @@ tape( 'if provided `NaN`, the accumulated value is `NaN` for at least `W` invoca if ( isnan( expected[ i ] ) ) { t.strictEqual( isnan( v ), true, 'returns expected value for window '+i ); t.strictEqual( isnan( acc() ), true, 'returns expected value for window '+i ); - } else if ( v === expected[ i ] ) { - t.strictEqual( v, expected[ i ], 'returns expected value for window: '+i ); } else { - delta = abs( v - expected[ i ] ); - tol = EPS * abs( expected[ i ] ); - t.strictEqual( delta < tol, true, 'window: '+i+'. expected: '+expected[ i ]+'. actual: '+v+'. tol: '+tol+'. delta: '+delta+'.' ); + t.strictEqual( isAlmostSameValue( v, expected[ i ], 1 ), true, 'returns expected value' ); t.strictEqual( acc(), v, 'returns expected value for window '+i ); } }