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
33 changes: 6 additions & 27 deletions lib/node_modules/@stdlib/stats/incr/nanmcv/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

var tape = require( 'tape' );
var randu = require( '@stdlib/random/base/randu' );
var abs = require( '@stdlib/math/base/special/abs' );
var EPS = require( '@stdlib/constants/float64/eps' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var sqrt = require( '@stdlib/math/base/special/sqrt' );
var zeros = require( '@stdlib/array/base/zeros' );
var incrnanmcv = require( './../lib' );
Expand Down Expand Up @@ -196,9 +195,7 @@ tape( 'the accumulator function computes a moving coefficient of variation incre
tape( 'if not provided an input value, the accumulator function returns the current accumulated value', function test( t ) {
var expected;
var actual;
var delta;
var data;
var tol;
var acc;
var i;

Expand All @@ -213,19 +210,15 @@ tape( 'if not provided an input value, the accumulator function returns the curr

expected = sqrt( 19.0 )/5.0;
actual = acc();
delta = abs( actual - expected );
tol = EPS * expected;

t.strictEqual( delta < tol, true, 'expected: '+expected+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' );
t.strictEqual( isAlmostSameValue( actual, expected, 0 ), true, 'returns expected value' );
t.end();
});

tape( 'if not provided an input value, the accumulator function returns the current accumulated value (known mean)', function test( t ) {
var expected;
var actual;
var delta;
var data;
var tol;
var acc;
var i;

Expand All @@ -240,10 +233,8 @@ tape( 'if not provided an input value, the accumulator function returns the curr

expected = sqrt( 12.666666666666666 )/5.0;
actual = acc();
delta = abs( actual - expected );
tol = EPS * expected;

t.strictEqual( delta < tol, true, 'expected: '+expected+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' );
t.strictEqual( isAlmostSameValue( actual, expected, 0 ), true, 'returns expected value' );
t.end();
});

Expand Down Expand Up @@ -302,10 +293,8 @@ tape( 'if the window size is `1` and the mean is known, the accumulator function
tape( 'if provided `NaN`, the value is ignored (unknown mean)', function test( t ) {
var expected;
var actual;
var delta;
var data;
var acc;
var tol;
var i;

acc = incrnanmcv( 3 );
Expand Down Expand Up @@ -360,9 +349,7 @@ tape( 'if provided `NaN`, the value is ignored (unknown mean)', function test( t
t.strictEqual( actual, null, 'returns expected value for window '+i );
t.strictEqual( acc(), null, 'returns expected value for window '+i );
} else {
delta = abs( actual - expected[ i ] );
tol = EPS * expected[ i ];
t.strictEqual( delta <= tol, true, 'expected: '+expected[i]+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' );
t.strictEqual( isAlmostSameValue( actual, expected[ i ], 0 ), true, 'returns expected value for window '+i );
t.strictEqual( acc(), actual, 'returns expected value for window '+i );
}
}
Expand All @@ -372,10 +359,8 @@ tape( 'if provided `NaN`, the value is ignored (unknown mean)', function test( t
tape( 'if provided `NaN`, the value is ignored (known mean)', function test( t ) {
var expected;
var actual;
var delta;
var data;
var acc;
var tol;
var i;

acc = incrnanmcv( 3, 3.14 );
Expand Down Expand Up @@ -430,9 +415,7 @@ tape( 'if provided `NaN`, the value is ignored (known mean)', function test( t )
t.strictEqual( actual, null, 'returns expected value for window '+i );
t.strictEqual( acc(), null, 'returns expected value for window '+i );
} else {
delta = abs( actual - expected[ i ] );
tol = EPS * expected[ i ];
t.strictEqual( delta <= tol, true, 'expected: '+expected[i]+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' );
t.strictEqual( isAlmostSameValue( actual, expected[ i ], 0 ), true, 'returns expected value for window '+i );
t.strictEqual( acc(), actual, 'returns expected value for window '+i );
}
}
Expand Down Expand Up @@ -508,10 +491,8 @@ tape( 'if provided `NaN`, the value is ignored (unknown mean, W=1)', function te
tape( 'if provided `NaN`, the value is ignored (known mean, W=1)', function test( t ) {
var expected;
var actual;
var delta;
var data;
var acc;
var tol;
var i;

acc = incrnanmcv( 1, 3.14 );
Expand Down Expand Up @@ -566,9 +547,7 @@ tape( 'if provided `NaN`, the value is ignored (known mean, W=1)', function test
t.strictEqual( actual, null, 'returns expected value for window '+i );
t.strictEqual( acc(), null, 'returns expected value for window '+i );
} else {
delta = abs( actual - expected[ i ] );
tol = EPS * expected[ i ];
t.strictEqual( delta <= tol, true, 'expected: '+expected[i]+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' );
t.strictEqual( isAlmostSameValue( actual, expected[ i ], 0 ), true, 'returns expected value for window '+i );
t.strictEqual( acc(), actual, 'returns expected value for window '+i );
}
}
Expand Down
Loading