diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/median/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/triangular/median/test/test.js index 9bb4fc9364f1..623c170cb033 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/triangular/median/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/median/test/test.js @@ -21,9 +21,8 @@ // MODULES // var tape = require( 'tape' ); -var abs = require( '@stdlib/math/base/special/abs' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var EPS = require( '@stdlib/constants/float64/eps' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var median = require( './../lib' ); @@ -74,8 +73,6 @@ tape( 'if provided parameters not satisfying `a <= c <= b`, the function returns tape( 'the function returns the median of a triangular distribution if provided parameters satisfy `c < (a + b) / 2`', function test( t ) { var expected; - var delta; - var tol; var a; var b; var c; @@ -87,22 +84,14 @@ tape( 'the function returns the median of a triangular distribution if provided b = data1.b; c = data1.c; for ( i = 0; i < expected.length; i++ ) { - y = median( a[i], b[i], c[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'a: '+a[i]+', b: '+b[i]+', c: '+c[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 1.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. a: '+a[i]+'. b: '+b[i]+'. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + y = median( a[ i ], b[ i ], c[ i ] ); + t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function returns the median of a triangular distribution if provided parameters satisfy `c >= (a + b) / 2`', function test( t ) { var expected; - var delta; - var tol; var a; var b; var c; @@ -114,14 +103,8 @@ tape( 'the function returns the median of a triangular distribution if provided b = data2.b; c = data2.c; for ( i = 0; i < expected.length; i++ ) { - y = median( a[i], b[i], c[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'a: '+a[i]+', b: '+b[i]+', c: '+c[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 1.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. a: '+a[i]+'. b: '+b[i]+'. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + y = median( a[ i ], b[ i ], c[ i ] ); + t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/median/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/triangular/median/test/test.native.js index e31d0838b71c..27b198b780d2 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/triangular/median/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/median/test/test.native.js @@ -24,8 +24,7 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var tryRequire = require( '@stdlib/utils/try-require' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var EPS = require( '@stdlib/constants/float64/eps' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); // FIXTURES // @@ -83,8 +82,6 @@ tape( 'if provided parameters not satisfying `a <= c <= b`, the function returns tape( 'the function returns the median of a triangular distribution if provided parameters satisfy `c < (a + b) / 2`', opts, function test( t ) { var expected; - var delta; - var tol; var a; var b; var c; @@ -96,22 +93,14 @@ tape( 'the function returns the median of a triangular distribution if provided b = data1.b; c = data1.c; for ( i = 0; i < expected.length; i++ ) { - y = median( a[i], b[i], c[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'a: '+a[i]+', b: '+b[i]+', c: '+c[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 1.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. a: '+a[i]+'. b: '+b[i]+'. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + y = median( a[ i ], b[ i ], c[ i ] ); + t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function returns the median of a triangular distribution if provided parameters satisfy `c >= (a + b) / 2`', opts, function test( t ) { var expected; - var delta; - var tol; var a; var b; var c; @@ -123,14 +112,8 @@ tape( 'the function returns the median of a triangular distribution if provided b = data2.b; c = data2.c; for ( i = 0; i < expected.length; i++ ) { - y = median( a[i], b[i], c[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'a: '+a[i]+', b: '+b[i]+', c: '+c[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 1.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. a: '+a[i]+'. b: '+b[i]+'. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + y = median( a[ i ], b[ i ], c[ i ] ); + t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' ); } t.end(); });