Skip to content

Commit 7be4b47

Browse files
committed
chore: clean-up
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent b6ad3e2 commit 7be4b47

File tree

10 files changed

+58
-64
lines changed

10 files changed

+58
-64
lines changed

lib/node_modules/@stdlib/stats/base/dists/laplace/logpdf/benchmark/benchmark.native.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
2525
var Float64Array = require( '@stdlib/array/float64' );
26-
var tryRequire = require( '@stdlib/utils/try-require' );
2726
var uniform = require( '@stdlib/random/base/uniform' );
2827
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2928
var EPS = require( '@stdlib/constants/float64/eps' );
29+
var tryRequire = require( '@stdlib/utils/try-require' );
3030
var pkg = require( './../package.json' ).name;
3131

3232

@@ -40,7 +40,7 @@ var opts = {
4040

4141
// MAIN //
4242

43-
bench( pkg, opts, function benchmark( b ) {
43+
bench( pkg+'::native', opts, function benchmark( b ) {
4444
var scale;
4545
var len;
4646
var mu;

lib/node_modules/@stdlib/stats/base/dists/laplace/mean/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ int main( void ) {
220220

221221
<!-- /.examples -->
222222

223+
</section>
224+
225+
<!-- /.c -->
226+
223227
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
224228

225229
<section class="references">

lib/node_modules/@stdlib/stats/base/dists/laplace/mean/benchmark/benchmark.native.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,27 @@
2020

2121
// MODULES //
2222

23+
var resolve = require( 'path' ).resolve;
2324
var bench = require( '@stdlib/bench' );
2425
var Float64Array = require( '@stdlib/array/float64' );
2526
var EPS = require( '@stdlib/constants/float64/eps' );
2627
var uniform = require( '@stdlib/random/base/uniform' );
2728
var isnan = require( '@stdlib/math/base/assert/is-nan' );
29+
var tryRequire = require( '@stdlib/utils/try-require' );
2830
var pkg = require( './../package.json' ).name;
29-
var mean = require( './../lib' );
31+
32+
33+
// VARIABLES //
34+
35+
var mean = tryRequire( resolve( __dirname, './../lib/native.js' ) );
36+
var opts = {
37+
'skip': ( mean instanceof Error )
38+
};
3039

3140

3241
// MAIN //
3342

34-
bench( pkg, function benchmark( b ) {
43+
bench( pkg+'::native', opts, function benchmark( b ) {
3544
var scale;
3645
var len;
3746
var mu;

lib/node_modules/@stdlib/stats/base/dists/laplace/mean/benchmark/c/benchmark.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,27 @@ static double random_uniform( const double min, const double max ) {
8686
return min + ( v*(max-min) );
8787
}
8888

89+
/**
90+
* Runs a benchmark.
91+
*
92+
* @return elapsed time in seconds
93+
*/
8994
static double benchmark( void ) {
9095
double elapsed;
91-
double scale;
92-
double mu;
96+
double mu[ 100 ];
97+
double b[ 100 ];
9398
double y;
9499
double t;
95100
int i;
96101

102+
for ( i = 0; i < 100; i++ ) {
103+
mu[ i ] = random_uniform( -50.0, 50.0 );
104+
b[ i ] = random_uniform( 1.0, 20.0 );
105+
}
106+
97107
t = tic();
98108
for ( i = 0; i < ITERATIONS; i++ ) {
99-
scale = random_uniform( 0.0, 20.0 );
100-
mu = random_uniform( -50.0, 50.0 );
101-
y = stdlib_base_dists_laplace_mean( scale, mu );
109+
y = stdlib_base_dists_laplace_mean( mu[ i%100 ], b[ i%100 ] );
102110
if ( y != y ) {
103111
printf( "should not return NaN\n" );
104112
break;

lib/node_modules/@stdlib/stats/base/dists/laplace/mean/test/test.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@
2222

2323
var tape = require( 'tape' );
2424
var isnan = require( '@stdlib/math/base/assert/is-nan' );
25-
var abs = require( '@stdlib/math/base/special/abs' );
2625
var PINF = require( '@stdlib/constants/float64/pinf' );
2726
var NINF = require( '@stdlib/constants/float64/ninf' );
28-
var EPS = require( '@stdlib/constants/float64/eps' );
2927
var mean = require( './../lib' );
3028

3129

@@ -79,8 +77,6 @@ tape( 'if provided a nonpositive `b`, the function returns `NaN`', function test
7977

8078
tape( 'the function returns the expected value of a Laplace distribution', function test( t ) {
8179
var expected;
82-
var delta;
83-
var tol;
8480
var mu;
8581
var b;
8682
var y;
@@ -91,15 +87,7 @@ tape( 'the function returns the expected value of a Laplace distribution', funct
9187
b = data.b;
9288
for ( i = 0; i < mu.length; i++ ) {
9389
y = mean( mu[i], b[i] );
94-
if ( expected[i] !== null ) {
95-
if ( y === expected[i] ) {
96-
t.equal( y, expected[i], 'mu:'+mu[i]+', b: '+b[i]+', y: '+y+', expected: '+expected[i] );
97-
} else {
98-
delta = abs( y - expected[ i ] );
99-
tol = 1.0 * EPS * abs( expected[ i ] );
100-
t.ok( delta <= tol, 'within tolerance. mu: '+mu[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
101-
}
102-
}
90+
t.equal( y, expected[i], 'mu:'+mu[i]+', b: '+b[i]+', y: '+y+', expected: '+expected[i] );
10391
}
10492
t.end();
10593
});

lib/node_modules/@stdlib/stats/base/dists/laplace/mean/test/test.native.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@
2323
var resolve = require( 'path' ).resolve;
2424
var tape = require( 'tape' );
2525
var tryRequire = require( '@stdlib/utils/try-require' );
26-
var abs = require( '@stdlib/math/base/special/abs' );
2726
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2827
var PINF = require( '@stdlib/constants/float64/pinf' );
2928
var NINF = require( '@stdlib/constants/float64/ninf' );
30-
var EPS = require( '@stdlib/constants/float64/eps' );
3129

3230

3331
// VARIABLES //
@@ -90,8 +88,6 @@ tape( 'if provided a nonpositive `b`, the function returns `NaN`', opts, functio
9088

9189
tape( 'the function returns the mean of a Laplace distribution', opts, function test( t ) {
9290
var expected;
93-
var delta;
94-
var tol;
9591
var mu;
9692
var b;
9793
var i;
@@ -102,13 +98,7 @@ tape( 'the function returns the mean of a Laplace distribution', opts, function
10298
mu = data.mu;
10399
for ( i = 0; i < expected.length; i++ ) {
104100
y = mean( mu[i], b[i] );
105-
if ( y === expected[i] ) {
106-
t.equal( y, expected[i], 'mu: '+mu[i]+', b: '+b[i]+', y: '+y+', expected: '+expected[i] );
107-
} else {
108-
delta = abs( y - expected[ i ] );
109-
tol = 1.0 * EPS * abs( expected[ i ] );
110-
t.ok( delta <= tol, 'within tolerance. mu: '+mu[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
111-
}
101+
t.equal( y, expected[i], 'mu: '+mu[i]+', b: '+b[i]+', y: '+y+', expected: '+expected[i] );
112102
}
113103
t.end();
114104
});

lib/node_modules/@stdlib/stats/base/dists/laplace/median/benchmark/benchmark.native.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,27 @@
2020

2121
// MODULES //
2222

23+
var resolve = require( 'path' ).resolve;
2324
var bench = require( '@stdlib/bench' );
2425
var Float64Array = require( '@stdlib/array/float64' );
2526
var EPS = require( '@stdlib/constants/float64/eps' );
2627
var uniform = require( '@stdlib/random/base/uniform' );
2728
var isnan = require( '@stdlib/math/base/assert/is-nan' );
29+
var tryRequire = require( '@stdlib/utils/try-require' );
2830
var pkg = require( './../package.json' ).name;
29-
var median = require( './../lib' );
31+
32+
33+
// VARIABLES //
34+
35+
var median = tryRequire( resolve( __dirname, './../lib/native.js' ) );
36+
var opts = {
37+
'skip': ( median instanceof Error )
38+
};
3039

3140

3241
// MAIN //
3342

34-
bench( pkg, function benchmark( b ) {
43+
bench( pkg+'::native', opts, function benchmark( b ) {
3544
var scale;
3645
var len;
3746
var mu;

lib/node_modules/@stdlib/stats/base/dists/laplace/median/benchmark/c/benchmark.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,27 @@ static double random_uniform( const double min, const double max ) {
8686
return min + ( v*(max-min) );
8787
}
8888

89+
/**
90+
* Runs a benchmark.
91+
*
92+
* @return elapsed time in seconds
93+
*/
8994
static double benchmark( void ) {
9095
double elapsed;
91-
double scale;
92-
double mu;
96+
double mu[ 100 ];
97+
double b[ 100 ];
9398
double y;
9499
double t;
95100
int i;
96101

102+
for ( i = 0; i < 100; i++ ) {
103+
mu[ i ] = random_uniform( -50.0, 50.0 );
104+
b[ i ] = random_uniform( 1.0, 20.0 );
105+
}
106+
97107
t = tic();
98108
for ( i = 0; i < ITERATIONS; i++ ) {
99-
mu = random_uniform( -50.0, 50.0 );
100-
scale = random_uniform( 0.0, 20.0 );
101-
y = stdlib_base_dists_laplace_median( mu, scale );
109+
y = stdlib_base_dists_laplace_median( mu[ i%100 ], b[ i%100 ] );
102110
if ( y != y ) {
103111
printf( "should not return NaN\n" );
104112
break;

lib/node_modules/@stdlib/stats/base/dists/laplace/median/test/test.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@
2222

2323
var tape = require( 'tape' );
2424
var isnan = require( '@stdlib/math/base/assert/is-nan' );
25-
var abs = require( '@stdlib/math/base/special/abs' );
2625
var PINF = require( '@stdlib/constants/float64/pinf' );
2726
var NINF = require( '@stdlib/constants/float64/ninf' );
28-
var EPS = require( '@stdlib/constants/float64/eps' );
2927
var median = require( './../lib' );
3028

3129

@@ -79,8 +77,6 @@ tape( 'if provided a nonpositive `b`, the function returns `NaN`', function test
7977

8078
tape( 'the function returns the median of a Laplace distribution', function test( t ) {
8179
var expected;
82-
var delta;
83-
var tol;
8480
var mu;
8581
var b;
8682
var y;
@@ -91,15 +87,7 @@ tape( 'the function returns the median of a Laplace distribution', function test
9187
b = data.b;
9288
for ( i = 0; i < mu.length; i++ ) {
9389
y = median( mu[i], b[i] );
94-
if ( expected[i] !== null ) {
95-
if ( y === expected[i] ) {
96-
t.equal( y, expected[i], 'mu:'+mu[i]+', b: '+b[i]+', y: '+y+', expected: '+expected[i] );
97-
} else {
98-
delta = abs( y - expected[ i ] );
99-
tol = 1.0 * EPS * abs( expected[ i ] );
100-
t.ok( delta <= tol, 'within tolerance. mu: '+mu[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
101-
}
102-
}
90+
t.equal( y, expected[i], 'mu:'+mu[i]+', b: '+b[i]+', y: '+y+', expected: '+expected[i] );
10391
}
10492
t.end();
10593
});

lib/node_modules/@stdlib/stats/base/dists/laplace/median/test/test.native.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@
2323
var resolve = require( 'path' ).resolve;
2424
var tape = require( 'tape' );
2525
var tryRequire = require( '@stdlib/utils/try-require' );
26-
var abs = require( '@stdlib/math/base/special/abs' );
2726
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2827
var PINF = require( '@stdlib/constants/float64/pinf' );
2928
var NINF = require( '@stdlib/constants/float64/ninf' );
30-
var EPS = require( '@stdlib/constants/float64/eps' );
3129

3230

3331
// VARIABLES //
@@ -90,8 +88,6 @@ tape( 'if provided a nonpositive `b`, the function returns `NaN`', opts, functio
9088

9189
tape( 'the function returns the median of a Laplace distribution', opts, function test( t ) {
9290
var expected;
93-
var delta;
94-
var tol;
9591
var mu;
9692
var b;
9793
var i;
@@ -102,13 +98,7 @@ tape( 'the function returns the median of a Laplace distribution', opts, functio
10298
mu = data.mu;
10399
for ( i = 0; i < expected.length; i++ ) {
104100
y = mean( mu[i], b[i] );
105-
if ( y === expected[i] ) {
106-
t.equal( y, expected[i], 'mu: '+mu[i]+', b: '+b[i]+', y: '+y+', expected: '+expected[i] );
107-
} else {
108-
delta = abs( y - expected[ i ] );
109-
tol = 1.0 * EPS * abs( expected[ i ] );
110-
t.ok( delta <= tol, 'within tolerance. mu: '+mu[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
111-
}
101+
t.equal( y, expected[i], 'mu: '+mu[i]+', b: '+b[i]+', y: '+y+', expected: '+expected[i] );
112102
}
113103
t.end();
114104
});

0 commit comments

Comments
 (0)