Skip to content

Commit 53e0e3a

Browse files
committed
Make pymc_random_discrete test helper more robust to discrete variables with large ranges
1 parent 11f207e commit 53e0e3a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pymc/tests/test_distributions_random.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,10 @@ def pymc_random_discrete(
144144
e = intX(ref_rand(size=size, **pt))
145145
o = np.atleast_1d(o).flatten()
146146
e = np.atleast_1d(e).flatten()
147-
observed, _ = np.histogram(o, bins=min(7, len(set(o))))
148-
expected, _ = np.histogram(e, bins=min(7, len(set(o))))
147+
bins = min(20, max(len(set(e)), len(set(o))))
148+
range = (min(min(e), min(o)), max(max(e), max(o)))
149+
observed, _ = np.histogram(o, bins=bins, range=range)
150+
expected, _ = np.histogram(e, bins=bins, range=range)
149151
if np.all(observed == expected):
150152
p = 1.0
151153
else:

0 commit comments

Comments
 (0)