Skip to content

Commit 0167558

Browse files
committed
chore: clean-up
Ref: 74b29a5 --- 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: na - 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 d477f6b commit 0167558

File tree

4 files changed

+31
-30
lines changed

4 files changed

+31
-30
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench/harness' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
26-
var uniform = require( '@stdlib/random/base/uniform' );
26+
var uniform = require( '@stdlib/random/array/uniform' );
2727
var tryRequire = require( '@stdlib/utils/try-require' );
2828
var pkg = require( './../package.json' ).name;
2929

@@ -39,14 +39,19 @@ var opts = {
3939
// MAIN //
4040

4141
bench( pkg+'::native', opts, function benchmark( b ) {
42+
var opts;
4243
var c;
4344
var y;
4445
var i;
4546

47+
opts = {
48+
'dtype': 'float64'
49+
};
50+
c = uniform( 100, 0.1, 10.0, opts );
51+
4652
b.tic();
4753
for ( i = 0; i < b.iterations; i++ ) {
48-
c = uniform( 0.1, 10.0 );
49-
y = median( c );
54+
y = median( c[ i % c.length ] );
5055
if ( isnan( y ) ) {
5156
b.fail( 'should not return NaN' );
5257
}

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,10 @@ static double benchmark( void ) {
9999
double y;
100100
int i;
101101

102-
// Generate test data:
103102
for ( i = 0; i < 100; i++ ) {
104103
c[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
105104
}
106105

107-
// Run the benchmark:
108106
t = tic();
109107
for ( i = 0; i < ITERATIONS; i++ ) {
110108
y = stdlib_base_dists_bradford_median( c[ i % 100 ] );
@@ -125,21 +123,17 @@ static double benchmark( void ) {
125123
*/
126124
int main( void ) {
127125
double elapsed;
128-
int count;
129126
int i;
130127

131128
// Use the current time to seed the pseudorandom number generator:
132129
srand( time( NULL ) );
133130

134131
print_version();
135-
count = 0;
136132
for ( i = 0; i < REPEATS; i++ ) {
137-
count += 1;
138133
printf( "# c::%s\n", NAME );
139134
elapsed = benchmark();
140-
printf( "ok %d benchmark finished\n", count );
141135
print_results( elapsed );
142-
printf( "\n" );
136+
printf( "ok %d benchmark finished\n", i+1 );
143137
}
144-
print_summary( count, count );
138+
print_summary( REPEATS, REPEATS );
145139
}

lib/node_modules/@stdlib/stats/base/dists/bradford/median/manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"libraries": [],
3535
"libpath": [],
3636
"dependencies": [
37+
"@stdlib/math/base/napi/unary",
3738
"@stdlib/math/base/assert/is-nan",
3839
"@stdlib/math/base/special/sqrt"
3940
]

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

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,38 +71,39 @@ tape( 'if provided a nonpositive `c`, the function returns `NaN`', opts, functio
7171
t.end();
7272
});
7373

74-
tape( 'the function returns the median of a Bradford distribution', opts, function test( t ) {
75-
var expected;
76-
var c;
77-
var i;
74+
tape( 'if provided `c <= 0`, the function returns `NaN`', opts, function test( t ) {
75+
var v;
76+
77+
v = median( 0.0 );
78+
t.equal( isnan( v ), true, 'returns expected value' );
79+
80+
v = median( -1.0 );
81+
t.equal( isnan( v ), true, 'returns expected value' );
82+
83+
v = median( NINF );
84+
t.equal( isnan( v ), true, 'returns expected value' );
7885

79-
expected = data.expected;
80-
c = data.x;
81-
for ( i = 0; i < c.length; i++ ) {
82-
t.equal( median( c[i] ), expected[ i ], 'returns expected value' );
83-
}
8486
t.end();
8587
});
8688

87-
tape( 'the function returns the median of a Bradford distribution (test fixtures)', opts, function test( t ) {
89+
tape( 'the function returns the median of a Bradford distribution', opts, function test( t ) {
8890
var expected;
8991
var delta;
9092
var tol;
91-
var c;
92-
var v;
9393
var i;
94+
var c;
95+
var y;
9496

95-
// We test against more stringent tolerance here given the sqrt in the implementation
96-
tol = 5.0 * EPS; // ~1.11e-15
9797
expected = data.expected;
9898
c = data.x;
9999
for ( i = 0; i < expected.length; i++ ) {
100-
v = median( c[i] );
101-
if ( v === expected[ i ] ) {
102-
t.equal( v, expected[ i ], 'returns expected value' );
100+
y = median( c[i] );
101+
if ( y === expected[i] ) {
102+
t.equal( y, expected[i], 'c: '+c[i]+', y: '+y+', expected: '+expected[i] );
103103
} else {
104-
delta = abs( v - expected[ i ] );
105-
t.ok( delta <= tol, 'within tolerance. c: ' + c[i] + '. Expected: ' + expected[i] + '. Actual: ' + v + '. Tolerance: ' + tol + '.' );
104+
delta = abs( y - expected[ i ] );
105+
tol = 7.2 * EPS * abs( expected[ i ] );
106+
t.ok( delta <= tol, 'within tolerance. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
106107
}
107108
}
108109
t.end();

0 commit comments

Comments
 (0)