Skip to content

Commit 625d924

Browse files
committed
chore: clean-up
Ref: 1acbc66 --- 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: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - 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: 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 4a955a9 commit 625d924

File tree

4 files changed

+44
-29
lines changed

4 files changed

+44
-29
lines changed

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,9 @@ 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
}
106-
107-
// Run the benchmark:
108105
t = tic();
109106
for ( i = 0; i < ITERATIONS; i++ ) {
110107
y = stdlib_base_dists_bradford_entropy( c[ i % 100 ] );
@@ -125,21 +122,17 @@ static double benchmark( void ) {
125122
*/
126123
int main( void ) {
127124
double elapsed;
128-
int count;
129125
int i;
130126

131127
// Use the current time to seed the pseudorandom number generator:
132128
srand( time( NULL ) );
133129

134130
print_version();
135-
count = 0;
136131
for ( i = 0; i < REPEATS; i++ ) {
137-
count += 1;
138132
printf( "# c::%s\n", NAME );
139133
elapsed = benchmark();
140-
printf( "ok %d benchmark finished\n", count );
141134
print_results( elapsed );
142-
printf( "\n" );
135+
printf( "ok %d benchmark finished\n", i+1 );
143136
}
144-
print_summary( count, count );
137+
print_summary( REPEATS, REPEATS );
145138
}

lib/node_modules/@stdlib/stats/base/dists/bradford/entropy/lib/main.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ var ln = require( '@stdlib/math/base/special/ln' );
5858
*/
5959
function entropy( c ) {
6060
var k;
61-
if (
62-
isnan( c ) ||
63-
c <= 0.0
64-
) {
61+
if ( isnan( c ) || c <= 0.0 ) {
6562
return NaN;
6663
}
6764
k = ln( 1.0 + c );

lib/node_modules/@stdlib/stats/base/dists/bradford/entropy/src/main.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@
3232
*/
3333
double stdlib_base_dists_bradford_entropy( const double c ) {
3434
double k;
35-
if (
36-
stdlib_base_is_nan( c ) ||
37-
c <= 0.0
38-
) {
35+
if ( stdlib_base_is_nan( c ) || c <= 0.0 ) {
3936
return 0.0/0.0; // NaN
4037
}
4138
k = stdlib_base_ln( 1.0 + c );

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

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var resolve = require( 'path' ).resolve;
2424
var tape = require( 'tape' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var abs = require( '@stdlib/math/base/special/abs' );
27+
var NINF = require( '@stdlib/constants/float64/ninf' );
2728
var EPS = require( '@stdlib/constants/float64/eps' );
2829
var tryRequire = require( '@stdlib/utils/try-require' );
2930

@@ -38,7 +39,8 @@ var opts = {
3839

3940
// FIXTURES //
4041

41-
var data = require( './fixtures/python/small_c.json' );
42+
var smallC = require( './fixtures/python/small_c.json' );
43+
var largeC = require( './fixtures/python/large_c.json' );
4244

4345

4446
// TESTS //
@@ -55,29 +57,32 @@ tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) {
5557
t.end();
5658
});
5759

58-
tape( 'the function returns `NaN` if provided a shape parameter which is not positive', opts, function test( t ) {
59-
var y;
60+
tape( 'if provided `c <= 0`, the function returns `NaN`', opts, function test( t ) {
61+
var v;
6062

61-
y = entropy( 0.0 );
62-
t.equal( isnan( y ), true, 'returns expected value' );
63+
v = entropy( 0.0 );
64+
t.equal( isnan( v ), true, 'returns expected value' );
6365

64-
y = entropy( -1.0 );
65-
t.equal( isnan( y ), true, 'returns expected value' );
66+
v = entropy( -1.0 );
67+
t.equal( isnan( v ), true, 'returns expected value' );
68+
69+
v = entropy( NINF );
70+
t.equal( isnan( v ), true, 'returns expected value' );
6671

6772
t.end();
6873
});
6974

70-
tape( 'the function returns the differential entropy of a Bradford distribution', opts, function test( t ) {
75+
tape( 'the function returns the differential entropy of a Bradford distribution given small parameter `c`', opts, function test( t ) {
7176
var expected;
7277
var delta;
7378
var tol;
79+
var i;
7480
var c;
7581
var y;
76-
var i;
7782

78-
expected = data.expected;
79-
c = data.c;
80-
for ( i = 0; i < c.length; i++ ) {
83+
expected = smallC.expected;
84+
c = smallC.c;
85+
for ( i = 0; i < expected.length; i++ ) {
8186
y = entropy( c[i] );
8287
if ( y === expected[i] ) {
8388
t.equal( y, expected[i], 'c: '+c[i]+', y: '+y+', expected: '+expected[i] );
@@ -89,3 +94,26 @@ tape( 'the function returns the differential entropy of a Bradford distribution'
8994
}
9095
t.end();
9196
});
97+
98+
tape( 'the function returns the differential entropy of a Bradford distribution given large parameter `c`', opts, function test( t ) {
99+
var expected;
100+
var delta;
101+
var tol;
102+
var i;
103+
var c;
104+
var y;
105+
106+
expected = largeC.expected;
107+
c = largeC.c;
108+
for ( i = 0; i < expected.length; i++ ) {
109+
y = entropy( c[i] );
110+
if ( y === expected[i] ) {
111+
t.equal( y, expected[i], 'c: '+c[i]+', y: '+y+', expected: '+expected[i] );
112+
} else {
113+
delta = abs( y - expected[ i ] );
114+
tol = 45.0 * EPS * abs( expected[ i ] );
115+
t.ok( delta <= tol, 'within tolerance. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
116+
}
117+
}
118+
t.end();
119+
});

0 commit comments

Comments
 (0)