Skip to content

Commit 87ed0ca

Browse files
Merge pull request scipy#21342 from mdhaber/fix_list_test
MAINT: stats: fix test that discrete distribution methods accept lists
2 parents 76bf366 + 2007157 commit 87ed0ca

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

scipy/stats/_distn_infrastructure.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3369,7 +3369,8 @@ def _pmf(self, k, *args):
33693369
return self._cdf(k, *args) - self._cdf(k-1, *args)
33703370

33713371
def _logpmf(self, k, *args):
3372-
return log(self._pmf(k, *args))
3372+
with np.errstate(divide='ignore'):
3373+
return log(self._pmf(k, *args))
33733374

33743375
def _logpxf(self, k, *args):
33753376
# continuous distributions have PDF, discrete have PMF, but sometimes

scipy/stats/tests/test_discrete_basic.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,15 +330,16 @@ def test_methods_with_lists(method, distname, args):
330330
dist = getattr(stats, distname)
331331
except TypeError:
332332
return
333+
dist_method = getattr(dist, method)
333334
if method in ['ppf', 'isf']:
334335
z = [0.1, 0.2]
335336
else:
336337
z = [0, 1]
337338
p2 = [[p]*2 for p in args]
338339
loc = [0, 1]
339-
result = dist.pmf(z, *p2, loc=loc)
340+
result = dist_method(z, *p2, loc=loc)
340341
npt.assert_allclose(result,
341-
[dist.pmf(*v) for v in zip(z, *p2, loc)],
342+
[dist_method(*v) for v in zip(z, *p2, loc)],
342343
rtol=1e-15, atol=1e-15)
343344

344345

0 commit comments

Comments
 (0)