Skip to content

Commit 0018e2f

Browse files
chore: added extra tests and conditions
1 parent 7500fac commit 0018e2f

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

lib/node_modules/@stdlib/stats/base/dists/binomial/variance/manifest.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"libpath": [],
4040
"dependencies": [
4141
"@stdlib/math/base/napi/binary",
42-
"@stdlib/math/base/assert/is-nan"
42+
"@stdlib/math/base/assert/is-nan",
43+
"@stdlib/math/base/assert/is-nonnegative-integer"
4344
]
4445
},
4546
{
@@ -54,7 +55,8 @@
5455
"libraries": [],
5556
"libpath": [],
5657
"dependencies": [
57-
"@stdlib/math/base/assert/is-nan"
58+
"@stdlib/math/base/assert/is-nan",
59+
"@stdlib/math/base/assert/is-nonnegative-integer"
5860
]
5961
},
6062
{
@@ -69,7 +71,8 @@
6971
"libraries": [],
7072
"libpath": [],
7173
"dependencies": [
72-
"@stdlib/math/base/assert/is-nan"
74+
"@stdlib/math/base/assert/is-nan",
75+
"@stdlib/math/base/assert/is-nonnegative-integer"
7376
]
7477
}
7578
]

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "stdlib/stats/base/dists/binomial/variance.h"
2020
#include "stdlib/math/base/assert/is_nan.h"
21+
#include "stdlib/math/base/assert/is_nonnegative_integer.h"
2122

2223
/**
2324
* Returns the variance of a binomial distribution.
@@ -36,7 +37,8 @@ double stdlib_base_dists_binomial_variance( const double n, const double p ) {
3637
stdlib_base_is_nan( p ) ||
3738
n < 0.0 ||
3839
p < 0.0 ||
39-
p > 1.0
40+
p > 1.0 ||
41+
!stdlib_base_is_nonnegative_integer( n )
4042
) {
4143
return 0.0 / 0.0;
4244
}

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,20 @@ tape( 'if provided `NaN` for any parameter, the function returns `NaN`', opts, f
5959
t.end();
6060
});
6161

62-
tape( 'if provided `n < 0`, the function returns `NaN`', opts, function test( t ) {
63-
var y;
62+
tape( 'if provided an `n` which is not a nonnegative integer, the function returns `NaN`', function test( t ) {
63+
var v;
6464

65-
y = variance( -1, 0.5 );
66-
t.equal( isnan( y ), true, 'returns NaN' );
65+
v = variance( 1.5, 0.5 );
66+
t.equal( isnan( v ), true, 'returns NaN' );
6767

68-
y = variance( NaN, 0.5 );
69-
t.equal( isnan( y ), true, 'returns NaN' );
68+
v = variance( -2, 0.5 );
69+
t.equal( isnan( v ), true, 'returns NaN' );
70+
71+
v = variance( -1, 0.5 );
72+
t.equal( isnan( v ), true, 'returns NaN' );
73+
74+
v = variance( 2.5, 0.5 );
75+
t.equal( isnan( v ), true, 'returns NaN' );
7076

7177
t.end();
7278
});

0 commit comments

Comments
 (0)