Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 7 additions & 35 deletions lib/node_modules/@stdlib/stats/incr/nanmapcorr/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );


Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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' );
}
}
}
Expand All @@ -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;
Expand All @@ -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 ];
Expand Down Expand Up @@ -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' );
}
}
}
Expand All @@ -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;
Expand Down Expand Up @@ -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();
});
Expand All @@ -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;
Expand Down Expand Up @@ -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();
});
Expand Down
Loading