Skip to content

Commit c729420

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: passed - task: lint_javascript_src status: passed - 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: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
1 parent a1fbf46 commit c729420

File tree

13 files changed

+82
-76
lines changed

13 files changed

+82
-76
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ y = mean( 0.5 );
7070
// returns ~0.399
7171
```
7272

73-
If provided `NaN` as any argument, the function returns `NaN`.
73+
If provided `NaN`, the function returns `NaN`.
7474

7575
```javascript
7676
var y = mean( NaN );

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

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

2323
var bench = require( '@stdlib/bench' );
24-
var Float64Array = require( '@stdlib/array/float64' );
25-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2625
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2726
var EPS = require( '@stdlib/constants/float64/eps' );
2827
var pkg = require( './../package.json' ).name;
@@ -33,19 +32,16 @@ var mean = require( './../lib' );
3332

3433
bench( pkg, function benchmark( b ) {
3534
var sigma;
36-
var len;
3735
var y;
3836
var i;
3937

40-
len = 100;
41-
sigma = new Float64Array( len );
42-
for ( i = 0; i < len; i++ ) {
43-
sigma[ i ] = ( randu() * 20.0 ) + EPS;
44-
}
38+
sigma = uniform( 100, EPS, 20.0, {
39+
'dtype': 'float64'
40+
});
4541

4642
b.tic();
4743
for ( i = 0; i < b.iterations; i++ ) {
48-
y = mean( sigma[ i % len ] );
44+
y = mean( sigma[ i%sigma.length ] );
4945
if ( isnan( y ) ) {
5046
b.fail( 'should not return NaN' );
5147
}

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

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

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var Float64Array = require( '@stdlib/array/float64' );
26-
var uniform = require( '@stdlib/random/base/uniform' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
2726
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2827
var tryRequire = require( '@stdlib/utils/try-require' );
2928
var EPS = require( '@stdlib/constants/float64/eps' );
29+
var format = require( '@stdlib/string/format' );
3030
var pkg = require( './../package.json' ).name;
3131

3232

@@ -40,20 +40,18 @@ var opts = {
4040

4141
// MAIN //
4242

43-
bench( pkg+'::native', opts, function benchmark( b ) {
43+
bench( format( '%s::native', pkg ), opts, function benchmark( b ) {
4444
var sigma;
45-
var len;
4645
var y;
4746
var i;
4847

49-
len = 100;
50-
sigma = new Float64Array( len );
51-
for ( i = 0; i < len; i++ ) {
52-
sigma[ i ] = uniform( EPS, 20.0 );
53-
}
48+
sigma = uniform( 100, EPS, 20.0, {
49+
'dtype': 'float64'
50+
});
51+
5452
b.tic();
5553
for ( i = 0; i < b.iterations; i++ ) {
56-
y = mean( sigma[ i % len ] );
54+
y = mean( sigma[ i%sigma.length ] );
5755
if ( isnan( y ) ) {
5856
b.fail( 'should not return NaN' );
5957
}

lib/node_modules/@stdlib/stats/base/dists/halfnormal/mean/docs/repl.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
Returns the expected value of a half-normal distribution with scale
44
parameter `σ`.
55

6-
If provided `NaN` as any argument, the function returns `NaN`.
7-
86
If provided `σ <= 0`, the function returns `NaN`.
97

108
Parameters
@@ -20,9 +18,9 @@
2018
Examples
2119
--------
2220
> var y = {{alias}}( 1.0 )
23-
~0.7978845608
21+
~0.79788
2422
> y = {{alias}}( 5.0 )
25-
~3.989422804
23+
~3.98942
2624
> y = {{alias}}( NaN )
2725
NaN
2826
> y = {{alias}}( 0.0 )

lib/node_modules/@stdlib/stats/base/dists/halfnormal/mean/docs/types/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
*
3131
* @example
3232
* var y = mean( 1.0 );
33-
* // returns ~0.7978845608
33+
* // returns ~0.79788
3434
*
3535
* @example
3636
* var y = mean( 5.0 );
37-
* // returns ~3.989422804
37+
* // returns ~3.98942
3838
*
3939
* @example
4040
* var y = mean( NaN );

lib/node_modules/@stdlib/stats/base/dists/halfnormal/mean/lib/main.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ var sqrt = require( '@stdlib/math/base/special/sqrt' );
2525
var PI = require( '@stdlib/constants/float64/pi' );
2626

2727

28+
// VARIABLES //
29+
30+
var SQRT_TWO_OVER_PI = sqrt( 2.0 / PI );
31+
32+
2833
// MAIN //
2934

3035
/**
@@ -50,13 +55,10 @@ var PI = require( '@stdlib/constants/float64/pi' );
5055
* // returns NaN
5156
*/
5257
function mean( sigma ) {
53-
if (
54-
isnan( sigma ) ||
55-
sigma <= 0.0
56-
) {
58+
if ( isnan( sigma ) || sigma <= 0.0 ) {
5759
return NaN;
5860
}
59-
return sigma * sqrt( 2.0 / PI );
61+
return sigma * SQRT_TWO_OVER_PI;
6062
}
6163

6264

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var addon = require( './../src/addon.node' );
3838
*
3939
* @example
4040
* var y = mean( 4.0 );
41-
* // returns ~3.1915382432114616
41+
* // returns ~3.192
4242
*
4343
* @example
4444
* var y = mean( NaN );

lib/node_modules/@stdlib/stats/base/dists/halfnormal/mean/src/addon.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@
1919
#include "stdlib/stats/base/dists/halfnormal/mean.h"
2020
#include "stdlib/math/base/napi/unary.h"
2121

22-
// cppcheck-suppress shadowFunction
2322
STDLIB_MATH_BASE_NAPI_MODULE_D_D( stdlib_base_dists_halfnormal_mean )

lib/node_modules/@stdlib/stats/base/dists/halfnormal/mean/src/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include "stdlib/math/base/special/sqrt.h"
2222
#include "stdlib/constants/float64/pi.h"
2323

24+
static const double SQRT_TWO_OVER_PI = stdlib_base_sqrt( 2.0 / STDLIB_CONSTANT_FLOAT64_PI );
25+
2426
/**
2527
* Returns the expected value for a half-normal distribution with scale parameter `sigma`.
2628
*
@@ -35,5 +37,5 @@ double stdlib_base_dists_halfnormal_mean( const double sigma ) {
3537
if ( stdlib_base_is_nan( sigma ) || sigma <= 0.0 ) {
3638
return 0.0 / 0.0; // NaN
3739
}
38-
return sigma * stdlib_base_sqrt( 2.0 / STDLIB_CONSTANT_FLOAT64_PI );
40+
return sigma * SQRT_TWO_OVER_PI;
3941
}

lib/node_modules/@stdlib/stats/base/dists/halfnormal/mean/test/fixtures/julia/runner.jl

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,19 @@ import JSON
2121
"""
2222
gen( sigma, name )
2323
24-
Generate fixture data for the mean of a half-normal distribution
25-
and write to file.
24+
Generate fixture data and write to file.
2625
2726
# Arguments
2827
29-
* `sigma::AbstractVector{<:Real}`: scale parameter (σ > 0)
28+
* `sigma`: scale parameter
3029
* `name::AbstractString`: output filename
30+
31+
# Examples
32+
33+
``` julia
34+
julia> sigma = rand( 1000 );
35+
julia> gen( sigma, \"data.json\" );
36+
```
3137
"""
3238
function gen( sigma, name )
3339
c = sqrt( 2.0 / π )
@@ -41,17 +47,28 @@ function gen( sigma, name )
4147
end
4248
end
4349

44-
data = Dict(
45-
"sigma" => sigma,
46-
"expected" => expected
47-
)
50+
# Store data to be written to file as a collection:
51+
data = Dict([
52+
("sigma", sigma),
53+
("expected", z)
54+
]);
4855

49-
open( name, "w" ) do io
50-
write( io, JSON.json( data ) )
51-
write( io, "\n" )
52-
end
56+
# Based on the script directory, create an output filepath:
57+
filepath = joinpath( dir, name )
58+
59+
# Write the data to the output filepath as JSON:
60+
outfile = open( filepath, "w" );
61+
write( outfile, JSON.json(data) );
62+
write( outfile, "\n" );
63+
close( outfile );
5364
end
5465

66+
# Get the filename:
67+
file = @__FILE__;
68+
69+
# Extract the directory in which this file resides:
70+
dir = dirname( file );
71+
5572
# Generate fixtures:
56-
sigma = rand( 1000 ) .* 5.0
57-
gen( sigma, "data.json" )
73+
sigma = rand( 1000 ) .* 5.0;
74+
gen( sigma, "data.json" );

0 commit comments

Comments
 (0)