Skip to content

Commit ccedb61

Browse files
committed
rewrite dict as literal, use list comprehension
1 parent 432bcda commit ccedb61

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

pymc3/memoize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def hashable(a) -> int:
9696
if isinstance(a, (tuple, list)):
9797
# lists are mutable and not hashable by default
9898
# for memoization, we need the hash to depend on the items
99-
return hash(tuple(map(hashable, a)))
99+
return hash(tuple(hashable(i) for i in a))
100100
try:
101101
return hash(a)
102102
except TypeError:

pymc3/tests/test_memo.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,11 @@ def test_hashing_of_rv_tuples():
5757
random=pm.Normal.dist(mu, sd).random,
5858
observed=obs,
5959
)
60-
print()
6160
for freerv in [mu, sd, dd] + pmodel.free_RVs:
6261
for structure in [
6362
freerv,
64-
dict(alpha=freerv, omega=None),
63+
{"alpha": freerv, "omega": None},
6564
[freerv, []],
6665
(freerv, []),
6766
]:
68-
print(f"testing hashing of: {structure}")
6967
assert isinstance(memoize.hashable(structure), int)

0 commit comments

Comments
 (0)