diff options
author | Moshe Looks <moshe@apprente.com> | 2018-07-24 11:47:22 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-24 11:47:22 -0700 |
commit | ea11a48cb670ee49a1a7a523133898bc7a644ed1 (patch) | |
tree | 901e4a1c33b4173681ccebb68123d582b1d2ffd0 | |
parent | 210f07f2e91727f7f2f687beb36e7d53445d1e72 (diff) | |
download | numpy-ea11a48cb670ee49a1a7a523133898bc7a644ed1.tar.gz |
BUG: have geometric() raise ValueError on p=0
Currently `np.random.geometric(0) => -9223372036854775808`
-rw-r--r-- | numpy/random/mtrand/mtrand.pyx | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/numpy/random/mtrand/mtrand.pyx b/numpy/random/mtrand/mtrand.pyx index ec759fdfb..62496286b 100644 --- a/numpy/random/mtrand/mtrand.pyx +++ b/numpy/random/mtrand/mtrand.pyx @@ -4143,15 +4143,15 @@ cdef class RandomState: if op.shape == (): fp = PyFloat_AsDouble(p) - if fp < 0.0: - raise ValueError("p < 0.0") + if fp <= 0.0: + raise ValueError("p <= 0.0") if fp > 1.0: raise ValueError("p > 1.0") return discd_array_sc(self.internal_state, rk_geometric, size, fp, self.lock) - if np.any(np.less(op, 0.0)): - raise ValueError("p < 0.0") + if np.any(np.less_equal(op, 0.0)): + raise ValueError("p <= 0.0") if np.any(np.greater(op, 1.0)): raise ValueError("p > 1.0") return discd_array(self.internal_state, rk_geometric, size, op, |