Skip to content

Commit e80ae7e

Browse files
committed
fix: update tests
1 parent 7c1a265 commit e80ae7e

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/variance/test/test.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,19 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24-
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
2524
var isnan = require( '@stdlib/math/base/assert/is-nan' );
26-
var randu = require( '@stdlib/random/base/randu' );
2725
var PINF = require( '@stdlib/constants/float64/pinf' );
2826
var NINF = require( '@stdlib/constants/float64/ninf' );
2927
var EPS = require( '@stdlib/constants/float64/eps' );
28+
var abs = require( '@stdlib/math/base/special/abs' );
3029
var variance = require( './../lib' );
3130

3231

32+
// FIXTURES //
33+
34+
var data = require( './fixtures/julia/data.json' );
35+
36+
3337
// TESTS //
3438

3539
tape( 'main export is a function', function test( t ) {
@@ -103,17 +107,26 @@ tape( 'if provided a nonpositive `b`, the function returns `NaN`', function test
103107
});
104108

105109
tape( 'the function returns the variance of a Kumaraswamy\'s double bounded distribution', function test( t ) {
110+
var expected;
111+
var delta;
112+
var tol;
106113
var a;
107114
var b;
108115
var i;
109116
var y;
110117

111-
// TODO: Add fixtures
112-
for ( i = 0; i < 100; i++ ) {
113-
a = ( randu()*5.0 ) + EPS;
114-
b = ( randu()*5.0 ) + EPS;
115-
y = variance( a, b );
116-
t.equal( isNumber( y ), true, 'returns a number' );
118+
expected = data.expected;
119+
a = data.a;
120+
b = data.b;
121+
for ( i = 0; i < expected.length; i++ ) {
122+
y = variance( a[i], b[i] );
123+
if ( y === expected[i] ) {
124+
t.equal( y, expected[i], 'a: '+a[i]+', b: '+b[i]+', y: '+y+', expected: '+expected[i] );
125+
} else {
126+
delta = abs( y - expected[ i ] );
127+
tol = 15000.0 * EPS * abs( expected[ i ] );
128+
t.ok( delta <= tol, 'within tolerance. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
129+
}
117130
}
118131
t.end();
119132
});

lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/variance/test/test.native.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ var tryRequire = require( '@stdlib/utils/try-require' );
2626
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2727
var PINF = require( '@stdlib/constants/float64/pinf' );
2828
var NINF = require( '@stdlib/constants/float64/ninf' );
29+
var EPS = require( '@stdlib/constants/float64/eps' );
30+
var abs = require( '@stdlib/math/base/special/abs' );
2931

3032

3133
// FIXTURES //
@@ -115,18 +117,24 @@ tape( 'if provided a nonpositive `b`, the function returns `NaN`', opts, functio
115117

116118
tape( 'the function returns the variance of a Kumaraswamy\'s double bounded distribution', opts, function test( t ) {
117119
var expected;
120+
var delta;
121+
var tol;
118122
var a;
119123
var b;
120-
var y;
121124
var i;
125+
var y;
122126

123127
expected = data.expected;
124128
a = data.a;
125129
b = data.b;
126-
for ( i in a ) {
127-
if (Object.prototype.hasOwnProperty.call(a, i)) {
128-
y = variance( a[i], b[i] );
129-
t.equal( y, expected[i], 'a :'+a[i]+', b: '+b[i]+', y: '+y+', expected: '+expected[i] );
130+
for ( i = 0; i < expected.length; i++ ) {
131+
y = variance( a[i], b[i] );
132+
if ( y === expected[i] ) {
133+
t.equal( y, expected[i], 'a: '+a[i]+', b: '+b[i]+', y: '+y+', expected: '+expected[i] );
134+
} else {
135+
delta = abs( y - expected[ i ] );
136+
tol = 15000.0 * EPS * abs( expected[ i ] );
137+
t.ok( delta <= tol, 'within tolerance. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
130138
}
131139
}
132140
t.end();

0 commit comments

Comments
 (0)