Skip to content

Commit bb1706f

Browse files
fix: resolve all the issues and added tests
1 parent a2e871f commit bb1706f

File tree

7 files changed

+103
-86
lines changed

7 files changed

+103
-86
lines changed

lib/node_modules/@stdlib/stats/base/dists/binomial/median/benchmark/c/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,4 @@ run: $(c_targets)
143143
clean:
144144
$(QUIET) -rm -f *.o *.out
145145

146-
.PHONY: clean
146+
.PHONY: clean

lib/node_modules/@stdlib/stats/base/dists/binomial/median/examples/c/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,4 @@ run: $(c_targets)
143143
clean:
144144
$(QUIET) -rm -f *.o *.out
145145

146-
.PHONY: clean
146+
.PHONY: clean

lib/node_modules/@stdlib/stats/base/dists/binomial/median/include/stdlib/stats/base/dists/binomial/median.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" {
2727
#endif
2828

2929
/**
30-
* Returns the median of a Binomial distribution with `n` trials and success probability `p`.
30+
* Returns the median of a binomial distribution with `n` trials and success probability `p`.
3131
*/
3232
double stdlib_base_dists_binomial_median( const double n, const double p );
3333

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,76 @@
11
{
2-
"options": {
2+
"options": {
3+
"task": "build",
4+
"wasm": false
5+
},
6+
"fields": [
7+
{
8+
"field": "src",
9+
"resolve": true,
10+
"relative": true
11+
},
12+
{
13+
"field": "include",
14+
"resolve": true,
15+
"relative": true
16+
},
17+
{
18+
"field": "libraries",
19+
"resolve": false,
20+
"relative": false
21+
},
22+
{
23+
"field": "libpath",
24+
"resolve": true,
25+
"relative": false
26+
}
27+
],
28+
"confs": [
29+
{
330
"task": "build",
4-
"wasm": false
31+
"wasm": false,
32+
"src": [
33+
"./src/main.c"
34+
],
35+
"include": [
36+
"./include"
37+
],
38+
"libraries": [],
39+
"libpath": [],
40+
"dependencies": [
41+
"@stdlib/math/base/napi/binary",
42+
"@stdlib/math/base/assert/is-nan"
43+
]
44+
},
45+
{
46+
"task": "benchmark",
47+
"wasm": false,
48+
"src": [
49+
"./src/main.c"
50+
],
51+
"include": [
52+
"./include"
53+
],
54+
"libraries": [],
55+
"libpath": [],
56+
"dependencies": [
57+
"@stdlib/math/base/assert/is-nan"
58+
]
559
},
6-
"fields": [
7-
{
8-
"field": "src",
9-
"resolve": true,
10-
"relative": true
11-
},
12-
{
13-
"field": "include",
14-
"resolve": true,
15-
"relative": true
16-
},
17-
{
18-
"field": "libraries",
19-
"resolve": false,
20-
"relative": false
21-
},
22-
{
23-
"field": "libpath",
24-
"resolve": true,
25-
"relative": false
26-
}
27-
],
28-
"confs": [
29-
{
30-
"task": "build",
31-
"wasm": false,
32-
"src": [
33-
"./src/main.c"
34-
],
35-
"include": [
36-
"./include"
37-
],
38-
"libraries": [],
39-
"libpath": [],
40-
"dependencies": [
41-
"@stdlib/math/base/napi/binary",
42-
"@stdlib/math/base/assert/is-nan"
43-
]
44-
},
45-
{
46-
"task": "benchmark",
47-
"wasm": false,
48-
"src": [
49-
"./src/main.c"
50-
],
51-
"include": [
52-
"./include"
53-
],
54-
"libraries": [],
55-
"libpath": [],
56-
"dependencies": [
57-
"@stdlib/math/base/assert/is-nan"
58-
]
59-
},
60-
{
61-
"task": "examples",
62-
"wasm": false,
63-
"src": [
64-
"./src/main.c"
65-
],
66-
"include": [
67-
"./include"
68-
],
69-
"libraries": [],
70-
"libpath": [],
71-
"dependencies": [
72-
"@stdlib/math/base/assert/is-nan"
73-
]
74-
}
75-
]
76-
}
60+
{
61+
"task": "examples",
62+
"wasm": false,
63+
"src": [
64+
"./src/main.c"
65+
],
66+
"include": [
67+
"./include"
68+
],
69+
"libraries": [],
70+
"libpath": [],
71+
"dependencies": [
72+
"@stdlib/math/base/assert/is-nan"
73+
]
74+
}
75+
]
76+
}

lib/node_modules/@stdlib/stats/base/dists/binomial/median/src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ clean-addon:
6767
#/
6868
clean: clean-addon
6969

70-
.PHONY: clean
70+
.PHONY: clean

lib/node_modules/@stdlib/stats/base/dists/binomial/median/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ double stdlib_base_dists_binomial_median( const double n, const double p ) {
4242
p > 1.0 ||
4343
n < 0
4444
) {
45-
return 0.0 / 0.0; // Return NaN for invalid inputs
45+
return 0.0 / 0.0; // NaN
4646
}
4747
return round( n * p );
4848
}

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

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,35 +56,52 @@ tape( 'if provided `NaN` for either `n` or `p`, the function returns `NaN`', opt
5656
v = median( 10, NaN );
5757
t.equal( isnan( v ), true, 'returns NaN' );
5858

59+
v = median( NaN, NaN );
60+
t.equal( isnan( v ), true, 'returns NaN' );
61+
5962
t.end();
6063
});
6164

62-
tape( 'if provided `n < 0`, the function returns `NaN`', opts, function test( t ) {
63-
var v = median( -1, 0.5 );
65+
tape( 'if provided an `n` which is not a nonnegative integer, the function returns `NaN`', function test( t ) {
66+
var v;
67+
68+
v = median( 1.5, 0.5 );
69+
t.equal( isnan( v ), true, 'returns NaN' );
70+
71+
v = median( -2, 0.5 );
72+
t.equal( isnan( v ), true, 'returns NaN' );
73+
74+
v = median( -1, 0.5 );
75+
t.equal( isnan( v ), true, 'returns NaN' );
76+
77+
v = median( 2.5, 0.5 );
78+
t.equal( isnan( v ), true, 'returns NaN' );
79+
80+
v = median( PINF, 0.5 );
6481
t.equal( isnan( v ), true, 'returns NaN' );
6582

6683
t.end();
6784
});
6885

69-
tape( 'if provided a success probability `p` outside of `[0,1]`, the function returns `NaN`', opts, function test( t ) {
86+
tape( 'if provided a success probability `p` outside of `[0,1]`, the function returns `NaN`', function test( t ) {
7087
var v;
7188

72-
v = median( 10, -0.1 );
89+
v = median( 20, -1.0 );
7390
t.equal( isnan( v ), true, 'returns NaN' );
7491

75-
v = median( 10, 1.1 );
92+
v = median( 20, 1.5 );
7693
t.equal( isnan( v ), true, 'returns NaN' );
7794

78-
v = median( 10, NINF );
95+
v = median( 20, NINF );
7996
t.equal( isnan( v ), true, 'returns NaN' );
8097

81-
v = median( 10, PINF );
98+
v = median( 20, PINF );
8299
t.equal( isnan( v ), true, 'returns NaN' );
83100

84101
t.end();
85102
});
86103

87-
tape( 'the function returns the median of a Binomial distribution', opts, function test( t ) {
104+
tape( 'the function returns the median of a binomial distribution', opts, function test( t ) {
88105
var expected;
89106
var i;
90107
var n;

0 commit comments

Comments
 (0)