8000 BUG: Fix None comparison giving FutureWarning in choice function. · numpy/numpy@275b1dd · GitHub
[go: up one dir, main page]

Skip to content

Commit 275b1dd

Browse files
committed
BUG: Fix None comparison giving FutureWarning in choice function.
This is in numpy/random/mtrand/mtrand.pyx where the choice function was using comparisons of the form `None != p`.
1 parent 56471a1 commit 275b1dd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

numpy/random/mtrand/mtrand.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ cdef class RandomState:
10681068
if pop_size is 0:
10691069
raise ValueError("a must be non-empty")
10701070

1071-
if None != p:
1071+
if p is not None:
10721072
d = len(p)
10731073
p = <ndarray>PyArray_ContiguousFromObject(p, NPY_DOUBLE, 1, 1)
10741074
pix = <double*>PyArray_DATA(p)
@@ -1090,7 +1090,7 @@ cdef class RandomState:
10901090

10911091
# Actual sampling
10921092
if replace:
1093-
if None != p:
1093+
if p is not None:
10941094
cdf = p.cumsum()
10951095
cdf /= cdf[-1]
10961096
uniform_samples = self.random_sample(shape)
@@ -1103,7 +1103,7 @@ cdef class RandomState:
11031103
raise ValueError("Cannot take a larger sample than "
11041104
"population when 'replace=False'")
11051105

1106-
if None != p:
1106+
if p is not None:
11071107
if np.count_nonzero(p > 0) < size:
11081108
raise ValueError("Fewer non-zero entries in p than size")
11091109
n_uniq = 0

0 commit comments

Comments
 (0)
0