Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions quantecon/random/tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ def test_return_types(self):
out = func(self.cdf, size)
assert_(out.shape == (size,))

def test_numpy_integer_size(self):
"""
A numpy integer `size` must request an array, as a Python `int`
does and as the jitted path already did. See #918.

"""
size = np.int64(10)
for func in self.draw_funcs:
out = func(self.cdf, size)
assert_(out.shape == (size,))

Comment thread
mmcky marked this conversation as resolved.
def test_return_values(self):
for func in self.draw_funcs:
out = func(self.cdf)
Expand Down
2 changes: 1 addition & 1 deletion quantecon/random/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def draw(cdf, size=None, rng=None):
"""
if rng is None:
rng = np.random
if isinstance(size, int):
if isinstance(size, (int, np.integer)):
rs = rng.random(size)
out = np.searchsorted(cdf, rs, side='right')
return out
Expand Down
Loading