Skip to content

Commit

Permalink
BUG: Make n a long int for np.random.multinomial
Browse files Browse the repository at this point in the history
  • Loading branch information
thalassemia authored and charris committed Nov 11, 2023
1 parent 249b5be commit 12b7b35
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion numpy/random/mtrand.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4253,7 +4253,7 @@ cdef class RandomState:
x.shape = tuple(final_shape)
return x

def multinomial(self, np.npy_intp n, object pvals, size=None):
def multinomial(self, long n, object pvals, size=None):
"""
multinomial(n, pvals, size=None)
Expand Down
3 changes: 3 additions & 0 deletions numpy/random/tests/test_randomstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ def test_multinomial_pvals_float32(self):
with pytest.raises(ValueError, match=match):
random.multinomial(1, pvals)

def test_multinomial_n_float(self):
# Non-index integer types should gracefully truncate floats
random.multinomial(100.5, [0.2, 0.8])

class TestSetState:
def setup_method(self):
Expand Down

0 comments on commit 12b7b35

Please sign in to comment.