Skip to content

Commit

Permalink
MAINT: improve rvs of randint in scipy.stats
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisb83 committed May 1, 2019
1 parent 05816ef commit eb48778
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions scipy/stats/_discrete_distns.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,9 @@ def _stats(self, low, high):

def _rvs(self, low, high):
"""An array of *size* random integers >= ``low`` and < ``high``."""
if np.asarray(low).size == 1 and np.asarray(high).size == 1:
# no need to vectorize in that case
return self._random_state.randint(low, high, size=self._size)
if self._size is not None:
# NumPy's RandomState.randint() doesn't broadcast its arguments.
# Use `broadcast_to()` to extend the shapes of low and high
Expand Down
2 changes: 1 addition & 1 deletion scipy/stats/tests/test_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def test_pdf(self):
assert_array_almost_equal(vals, out)

def test_cdf(self):
x = np.linspace(0,36,100)
x = np.linspace(0, 36, 100)
k = numpy.floor(x)
out = numpy.select([k >= 30, k >= 5], [1.0, (k-5.0+1)/(30-5.0)], 0)
vals = stats.randint.cdf(x, 5, 30)
Expand Down

0 comments on commit eb48778

Please sign in to comment.