Skip to content

Commit 90d0d11

Browse files
authored
chore: update random value generation and test messages
PR-URL: #6346 Reviewed-by: Philipp Burckhardt <[email protected]>
1 parent ad12a89 commit 90d0d11

File tree

13 files changed

+140
-127
lines changed

13 files changed

+140
-127
lines changed

lib/node_modules/@stdlib/math/base/special/gammasgn/benchmark/benchmark.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var pkg = require( './../package.json' ).name;
2727
var gammasgn = require( './../lib' );
@@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) {
3434
var y;
3535
var i;
3636

37+
x = uniform( 100, 0.0, 171.0 );
38+
3739
b.tic();
3840
for ( i = 0; i < b.iterations; i++ ) {
39-
x = ( randu()*171.0 ) - 0.0;
40-
y = gammasgn( x );
41+
y = gammasgn( x[ i%x.length ] );
4142
if ( isnan( y ) ) {
4243
b.fail( 'should not return NaN' );
4344
}

lib/node_modules/@stdlib/math/base/special/gammasgn/benchmark/benchmark.native.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var randu = require( '@stdlib/random/base/randu' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
2626
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2727
var tryRequire = require( '@stdlib/utils/try-require' );
2828
var pkg = require( './../package.json' ).name;
@@ -43,10 +43,11 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4343
var y;
4444
var i;
4545

46+
x = uniform( 100, 0.0, 171.0 );
47+
4648
b.tic();
4749
for ( i = 0; i < b.iterations; i++ ) {
48-
x = ( randu() * 171.0 ) - 0.0;
49-
y = gammasgn( x );
50+
y = gammasgn( x[ i%x.length ] );
5051
if ( isnan( y ) ) {
5152
b.fail( 'should not return NaN' );
5253
}

lib/node_modules/@stdlib/math/base/special/gammasgn/benchmark/c/native/benchmark.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,18 @@ static double rand_double( void ) {
9191
*/
9292
static double benchmark( void ) {
9393
double elapsed;
94-
double x;
94+
double x[ 100 ];
9595
double y;
9696
double t;
9797
int i;
9898

99+
for ( i = 0; i < 100; i++ ) {
100+
x[ i ] = ( 171.0 * rand_double() ) - 0.0;
101+
}
102+
99103
t = tic();
100104
for ( i = 0; i < ITERATIONS; i++ ) {
101-
x = ( 171.0 * rand_double() ) - 0.0;
102-
y = stdlib_base_gammasgn( x );
105+
y = stdlib_base_gammasgn( x[ i%100 ] );
103106
if ( y != y ) {
104107
printf( "should not return NaN\n" );
105108
break;

lib/node_modules/@stdlib/math/base/special/gammasgn/test/test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,19 @@ tape( 'the function computes the sign of the gamma function for medium negative
125125

126126
tape( 'the function returns `NaN` if provided `NaN`', function test( t ) {
127127
var v = gammasgn( NaN );
128-
t.equal( isnan( v ), true, 'returns NaN' );
128+
t.equal( isnan( v ), true, 'returns expected value' );
129129
t.end();
130130
});
131131

132132
tape( 'the function returns `+0` if provided `+0`', function test( t ) {
133133
var v = gammasgn( +0.0 );
134-
t.equal( isPositiveZero( v ), true, 'returns 0' );
134+
t.equal( isPositiveZero( v ), true, 'returns expected value' );
135135
t.end();
136136
});
137137

138138
tape( 'the function returns `+0` if provided `-0`', function test( t ) {
139139
var v = gammasgn( -0.0 );
140-
t.equal( isPositiveZero( v ), true, 'returns 0' );
140+
t.equal( isPositiveZero( v ), true, 'returns expected value' );
141141
t.end();
142142
});
143143

@@ -147,7 +147,7 @@ tape( 'the function returns `+0` if provided a negative integer', function test(
147147

148148
for ( i = 0; i >= -100; i-- ) {
149149
v = gammasgn( i );
150-
t.equal( isPositiveZero( v ), true, 'returns 0' );
150+
t.equal( isPositiveZero( v ), true, 'returns expected value' );
151151
}
152152
t.end();
153153
});

lib/node_modules/@stdlib/math/base/special/gammasgn/test/test.native.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,19 @@ tape( 'the function computes the sign of the gamma function for medium negative
134134

135135
tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) {
136136
var v = gammasgn( NaN );
137-
t.equal( isnan( v ), true, 'returns NaN' );
137+
t.equal( isnan( v ), true, 'returns expected value' );
138138
t.end();
139139
});
140140

141141
tape( 'the function returns `+0` if provided `+0`', opts, function test( t ) {
142142
var v = gammasgn( +0.0 );
143-
t.equal( isPositiveZero( v ), true, 'returns 0' );
143+
t.equal( isPositiveZero( v ), true, 'returns expected value' );
144144
t.end();
145145
});
146146

147147
tape( 'the function returns `+0` if provided `-0`', opts, function test( t ) {
148148
var v = gammasgn( -0.0 );
149-
t.equal( isPositiveZero( v ), true, 'returns 0' );
149+
t.equal( isPositiveZero( v ), true, 'returns expected value' );
150150
t.end();
151151
});
152152

@@ -156,7 +156,7 @@ tape( 'the function returns `+0` if provided a negative integer', opts, function
156156

157157
for ( i = 0; i >= -100; i-- ) {
158158
v = gammasgn( i );
159-
t.equal( isPositiveZero( v ), true, 'returns 0' );
159+
t.equal( isPositiveZero( v ), true, 'returns expected value' );
160160
}
161161
t.end();
162162
});

lib/node_modules/@stdlib/math/base/special/kernel-betainc/benchmark/benchmark.js

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

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var EPS = require( '@stdlib/constants/float64/eps' );
2727
var pkg = require( './../package.json' ).name;
@@ -37,13 +37,14 @@ bench( pkg+'::regularized,upper', function benchmark( assert ) {
3737
var b;
3838
var i;
3939

40+
x = uniform( 100, 0.0, 1.0 );
41+
a = uniform( 100, EPS, 1000.0 );
42+
b = uniform( 100, EPS, 1000.0 );
43+
4044
out = [ 0.0, 0.0 ];
4145
assert.tic();
4246
for ( i = 0; i < assert.iterations; i++ ) {
43-
x = randu();
44-
a = ( randu()*1000.0 ) + EPS;
45-
b = ( randu()*1000.0 ) + EPS;
46-
out = kernelBetainc( x, a, b, true, true, out, 1, 0 );
47+
out = kernelBetainc( x[ i%x.length ], a[ i%a.length ], b[ i%b.length ], true, true, out, 1, 0 );
4748
if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) {
4849
assert.fail( 'should not return NaN' );
4950
}
@@ -63,13 +64,14 @@ bench( pkg+'::unregularized,upper', function benchmark( assert ) {
6364
var b;
6465
var i;
6566

67+
x = uniform( 100, 0.0, 1.0 );
68+
a = uniform( 100, EPS, 1000.0 );
69+
b = uniform( 100, EPS, 1000.0 );
70+
6671
out = [ 0.0, 0.0 ];
6772
assert.tic();
6873
for ( i = 0; i < assert.iterations; i++ ) {
69-
x = randu();
70-
a = ( randu()*1000.0 ) + EPS;
71-
b = ( randu()*1000.0 ) + EPS;
72-
out = kernelBetainc( x, a, b, false, true, out, 1, 0 );
74+
out = kernelBetainc( x[ i%x.length ], a[ i%a.length ], b[ i%b.length ], false, true, out, 1, 0 );
7375
if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) {
7476
assert.fail( 'should not return NaN' );
7577
}
@@ -89,13 +91,14 @@ bench( pkg+'::regularized,lower', function benchmark( assert ) {
8991
var b;
9092
var i;
9193

94+
x = uniform( 100, 0.0, 1.0 );
95+
a = uniform( 100, EPS, 1000.0 );
96+
b = uniform( 100, EPS, 1000.0 );
97+
9298
out = [ 0.0, 0.0 ];
9399
assert.tic();
94100
for ( i = 0; i < assert.iterations; i++ ) {
95-
x = randu();
96-
a = ( randu()*1000.0 ) + EPS;
97-
b = ( randu()*1000.0 ) + EPS;
98-
out = kernelBetainc( x, a, b, true, false, out, 1, 0 );
101+
out = kernelBetainc( x[ i%x.length ], a[ i%a.length ], b[ i%b.length ], true, false, out, 1, 0 );
99102
if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) {
100103
assert.fail( 'should not return NaN' );
101104
}
@@ -115,13 +118,14 @@ bench( pkg+'::unregularized,lower', function benchmark( assert ) {
115118
var b;
116119
var i;
117120

121+
x = uniform( 100, 0.0, 1.0 );
122+
a = uniform( 100, EPS, 1000.0 );
123+
b = uniform( 100, EPS, 1000.0 );
124+
118125
out = [ 0.0, 0.0 ];
119126
assert.tic();
120127
for ( i = 0; i < assert.iterations; i++ ) {
121-
x = randu();
122-
a = ( randu()*1000.0 ) + EPS;
123-
b = ( randu()*1000.0 ) + EPS;
124-
out = kernelBetainc( x, a, b, false, false, out, 1, 0 );
128+
out = kernelBetainc( x[ i%x.length ], a[ i%a.length ], b[ i%b.length ], false, false, out, 1, 0 );
125129
if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) {
126130
assert.fail( 'should not return NaN' );
127131
}

lib/node_modules/@stdlib/math/base/special/kernel-betainc/test/test.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,74 +36,74 @@ tape( 'main export is a function', function test( t ) {
3636

3737
tape( 'the function returns `[ NaN, NaN ]` if `x` is outside `[0,1]`', function test( t ) {
3838
var val = kernelBetainc( -0.2, 1.0, 1.0, true, true );
39-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
39+
t.equal( isNaNArray( val ), true, 'returns expected value' );
4040

4141
val = kernelBetainc( -0.2, 1.0, 1.0, false, false );
42-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
42+
t.equal( isNaNArray( val ), true, 'returns expected value' );
4343

4444
val = kernelBetainc( -0.2, 1.0, 1.0, true, false );
45-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
45+
t.equal( isNaNArray( val ), true, 'returns expected value' );
4646

4747
val = kernelBetainc( -0.2, 1.0, 1.0, false, true );
48-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
48+
t.equal( isNaNArray( val ), true, 'returns expected value' );
4949

5050
val = kernelBetainc( 1.1, 1.0, 1.0, true, true );
51-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
51+
t.equal( isNaNArray( val ), true, 'returns expected value' );
5252

5353
val = kernelBetainc( 1.1, 1.0, 1.0, false, false );
54-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
54+
t.equal( isNaNArray( val ), true, 'returns expected value' );
5555

5656
val = kernelBetainc( 1.1, 1.0, 1.0, false, true );
57-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
57+
t.equal( isNaNArray( val ), true, 'returns expected value' );
5858

5959
val = kernelBetainc( 1.1, 1.0, 1.0, true, false );
60-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
60+
t.equal( isNaNArray( val ), true, 'returns expected value' );
6161

6262
t.end();
6363
});
6464

6565
tape( 'the function returns `[ NaN, NaN ]` if `x` is `NaN`', function test( t ) {
6666
var val = kernelBetainc( NaN, 1.0, 1.0, true, true );
67-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
67+
t.equal( isNaNArray( val ), true, 'returns expected value' );
6868
t.end();
6969
});
7070

7171
tape( 'the function returns `[ NaN, NaN ]` if negative `a` or `b`', function test( t ) {
7272
var val = kernelBetainc( 0.5, -1.0, 1.0, true, true );
73-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
73+
t.equal( isNaNArray( val ), true, 'returns expected value' );
7474

7575
val = kernelBetainc( 0.5, -1.0, 1.0, false, false );
76-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
76+
t.equal( isNaNArray( val ), true, 'returns expected value' );
7777

7878
val = kernelBetainc( 0.5, -1.0, 1.0, true, false );
79-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
79+
t.equal( isNaNArray( val ), true, 'returns expected value' );
8080

8181
val = kernelBetainc( 0.5, -1.0, 1.0, false, true );
82-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
82+
t.equal( isNaNArray( val ), true, 'returns expected value' );
8383

8484
val = kernelBetainc( 0.5, 1.0, -1.0, true, true );
85-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
85+
t.equal( isNaNArray( val ), true, 'returns expected value' );
8686

8787
val = kernelBetainc( 0.5, 1.0, -1.0, false, false );
88-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
88+
t.equal( isNaNArray( val ), true, 'returns expected value' );
8989

9090
val = kernelBetainc( 0.5, 1.0, -1.0, true, false );
91-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
91+
t.equal( isNaNArray( val ), true, 'returns expected value' );
9292

9393
val = kernelBetainc( 0.5, 1.0, -1.0, false, true );
94-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
94+
t.equal( isNaNArray( val ), true, 'returns expected value' );
9595

9696
val = kernelBetainc( 0.5, -1.0, -1.0, true, true );
97-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
97+
t.equal( isNaNArray( val ), true, 'returns expected value' );
9898

9999
val = kernelBetainc( 0.5, -1.0, -1.0, false, false );
100-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
100+
t.equal( isNaNArray( val ), true, 'returns expected value' );
101101

102102
val = kernelBetainc( 0.5, -1.0, -1.0, false, true );
103-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
103+
t.equal( isNaNArray( val ), true, 'returns expected value' );
104104

105105
val = kernelBetainc( 0.5, -1.0, -1.0, true, false );
106-
t.equal( isNaNArray( val ), true, 'returns array of NaNs' );
106+
t.equal( isNaNArray( val ), true, 'returns expected value' );
107107

108108
t.end();
109109
});

lib/node_modules/@stdlib/math/base/special/kernel-betaincinv/benchmark/benchmark.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2525
var isNumberArray = require( '@stdlib/assert/is-number-array' );
2626
var EPS = require( '@stdlib/constants/float64/eps' );
2727
var pkg = require( './../package.json' ).name;
@@ -37,12 +37,13 @@ bench( pkg, function benchmark( assert ) {
3737
var b;
3838
var i;
3939

40+
p = uniform( 100, 0.0, 1.0 );
41+
a = uniform( 100, EPS, 1000.0 );
42+
b = uniform( 100, EPS, 1000.0 );
43+
4044
assert.tic();
4145
for ( i = 0; i < assert.iterations; i++ ) {
42-
p = randu();
43-
a = ( randu()*1000.0 ) + EPS;
44-
b = ( randu()*1000.0 ) + EPS;
45-
y = kernelBetaincinv( a, b, p, 1.0-p );
46+
y = kernelBetaincinv( a[ i%a.length ], b[ i%b.length ], p[ i%p.length ], 1.0-p );
4647
if ( !isNumberArray( y ) ) {
4748
assert.fail( 'should return an array of numbers' );
4849
}

lib/node_modules/@stdlib/math/base/special/lcm/benchmark/benchmark.js

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

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
25-
var round = require( '@stdlib/math/base/special/round' );
24+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
2625
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2726
var pkg = require( './../package.json' ).name;
2827
var lcm = require( './../lib' );
@@ -36,11 +35,12 @@ bench( pkg, function benchmark( b ) {
3635
var z;
3736
var i;
3837

38+
x = discreteUniform( 100, 0, 50 );
39+
y = discreteUniform( 100, 0, 50 );
40+
3941
b.tic();
4042
for ( i = 0; i < b.iterations; i++ ) {
41-
x = round( randu()*50.0 );
42-
y = round( randu()*50.0 );
43-
z = lcm( x, y );
43+
z = lcm( x[ i%x.length ], y[ i%y.length ] );
4444
if ( isnan( z ) ) {
4545
b.fail( 'should not return NaN' );
4646
}

lib/node_modules/@stdlib/math/base/special/lcm/benchmark/benchmark.native.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var randu = require( '@stdlib/random/base/randu' );
26-
var round = require( '@stdlib/math/base/special/round' );
25+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
2726
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2827
var tryRequire = require( '@stdlib/utils/try-require' );
2928
var pkg = require( './../package.json' ).name;
@@ -45,11 +44,12 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4544
var z;
4645
var i;
4746

47+
x = discreteUniform( 100, 0, 50 );
48+
y = discreteUniform( 100, 0, 50 );
49+
4850
b.tic();
4951
for ( i = 0; i < b.iterations; i++ ) {
50-
x = round( randu() * 50.0 );
51-
y = round( randu() * 50.0 );
52-
z = lcm( x, y );
52+
z = lcm( x[ i%x.length ], y[ i%y.length ] );
5353
if ( isnan( z ) ) {
5454
b.fail( 'should not return NaN' );
5555
}

0 commit comments

Comments
 (0)