Skip to content

Commit db982de

Browse files
committed
refactor: collapse exact-match guard in stats/base/dists/wald tests
Propagates the test-assertion simplification from eeaf7c4 ("refactor: reduce number of arithmetic operations") to sibling Wald distribution packages (pdf, variance, skewness). Replaces the redundant `if ( y === expected[i] ) { t.strictEqual( y, ... ) } else { t.ok( isAlmostSameValue( y, expected[i], TOL ) ) }` block with an unconditional `t.strictEqual( isAlmostSameValue( y, expected[i], TOL ), true, ... )`, since `isAlmostSameValue` already accepts exact matches.
1 parent 642af21 commit db982de

7 files changed

Lines changed: 7 additions & 35 deletions

File tree

lib/node_modules/@stdlib/stats/base/dists/wald/pdf/test/test.factory.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,7 @@ tape( 'the created function evaluates the pdf for `x` given parameters `mu` and
256256
for ( i = 0; i < x.length; i++ ) {
257257
pdf = factory( mu[i], lambda[i] );
258258
y = pdf( x[i] );
259-
if ( y === expected[i] ) {
260-
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu: '+mu[i]+', lambda: '+lambda[i]+', y: '+y+', expected: '+expected[i] );
261-
} else {
262-
t.ok( isAlmostSameValue( y, expected[i], 1500 ), 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'.' );
263-
}
259+
t.strictEqual( isAlmostSameValue( y, expected[i], 1500 ), true, 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'.' );
264260
}
265261
t.end();
266262
});

lib/node_modules/@stdlib/stats/base/dists/wald/pdf/test/test.native.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,7 @@ tape( 'the function evaluates the pdf for `x` given parameters `mu` and `lambda`
217217
lambda = data.lambda;
218218
for ( i = 0; i < x.length; i++ ) {
219219
y = pdf( x[i], mu[i], lambda[i] );
220-
if ( y === expected[i] ) {
221-
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu:'+mu[i]+', lambda: '+lambda[i]+', y: '+y+', expected: '+expected[i] );
222-
} else {
223-
t.ok( isAlmostSameValue( y, expected[i], 1500 ), 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'.' );
224-
}
220+
t.strictEqual( isAlmostSameValue( y, expected[i], 1500 ), true, 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'.' );
225221
}
226222
t.end();
227223
});

lib/node_modules/@stdlib/stats/base/dists/wald/pdf/test/test.pdf.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,7 @@ tape( 'the function evaluates the pdf for `x` given parameters `mu` and `lambda`
208208
lambda = data.lambda;
209209
for ( i = 0; i < x.length; i++ ) {
210210
y = pdf( x[i], mu[i], lambda[i] );
211-
if ( y === expected[i] ) {
212-
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu:'+mu[i]+', lambda: '+lambda[i]+', y: '+y+', expected: '+expected[i] );
213-
} else {
214-
t.ok( isAlmostSameValue( y, expected[i], 1500 ), 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'.' );
215-
}
211+
t.strictEqual( isAlmostSameValue( y, expected[i], 1500 ), true, 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'.' );
216212
}
217213
t.end();
218214
});

lib/node_modules/@stdlib/stats/base/dists/wald/skewness/test/test.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,7 @@ tape( 'the function returns the skewness of a Wald distribution', function test(
111111
lambda = data.lambda;
112112
for ( i = 0; i < mu.length; i++ ) {
113113
y = skewness( mu[i], lambda[i] );
114-
if ( y === expected[i] ) {
115-
t.strictEqual( y, expected[i], 'mu:'+mu[i]+', lambda: '+lambda[i]+', y: '+y+', expected: '+expected[i] );
116-
} else {
117-
t.ok( isAlmostSameValue( y, expected[i], 20 ), 'within tolerance. mu: '+mu[i]+'. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'.' );
118-
}
114+
t.strictEqual( isAlmostSameValue( y, expected[i], 20 ), true, 'within tolerance. mu: '+mu[i]+'. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'.' );
119115
}
120116
t.end();
121117
});

lib/node_modules/@stdlib/stats/base/dists/wald/skewness/test/test.native.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,7 @@ tape( 'the function returns the skewness of a Wald distribution', opts, function
120120
lambda = data.lambda;
121121
for ( i = 0; i < mu.length; i++ ) {
122122
y = skewness( mu[i], lambda[i] );
123-
if ( y === expected[i] ) {
124-
t.strictEqual( y, expected[i], 'mu:'+mu[i]+', lambda: '+lambda[i]+', y: '+y+', expected: '+expected[i] );
125-
} else {
126-
t.ok( isAlmostSameValue( y, expected[i], 20 ), 'within tolerance. mu: '+mu[i]+'. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'.' );
127-
}
123+
t.strictEqual( isAlmostSameValue( y, expected[i], 20 ), true, 'within tolerance. mu: '+mu[i]+'. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'.' );
128124
}
129125
t.end();
130126
});

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,7 @@ tape( 'the function returns the variance of a Wald distribution', function test(
111111
lambda = data.lambda;
112112
for ( i = 0; i < mu.length; i++ ) {
113113
y = variance( mu[i], lambda[i] );
114-
if ( y === expected[i] ) {
115-
t.strictEqual( y, expected[i], 'mu:'+mu[i]+', lambda: '+lambda[i]+', y: '+y+', expected: '+expected[i] );
116-
} else {
117-
t.ok( isAlmostSameValue( y, expected[i], 20 ), 'within tolerance. mu: '+mu[i]+'. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'.' );
118-
}
114+
t.strictEqual( isAlmostSameValue( y, expected[i], 20 ), true, 'within tolerance. mu: '+mu[i]+'. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'.' );
119115
}
120116
t.end();
121117
});

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,7 @@ tape( 'the function returns the variance of a Wald distribution', opts, function
120120
lambda = data.lambda;
121121
for ( i = 0; i < mu.length; i++ ) {
122122
y = variance( mu[i], lambda[i] );
123-
if ( y === expected[i] ) {
124-
t.strictEqual( y, expected[i], 'mu:'+mu[i]+', lambda: '+lambda[i]+', y: '+y+', expected: '+expected[i] );
125-
} else {
126-
t.ok( isAlmostSameValue( y, expected[i], 20 ), 'within tolerance. mu: '+mu[i]+'. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'.' );
127-
}
123+
t.strictEqual( isAlmostSameValue( y, expected[i], 20 ), true, 'within tolerance. mu: '+mu[i]+'. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'.' );
128124
}
129125
t.end();
130126
});

0 commit comments

Comments
 (0)