Skip to content

Commit b536e6d

Browse files
authored
Fix all_events to respect variables already in the evidence (#1274)
In all_events (probability4e.py), if a variable X is already fixed in the evidence e, don't enumerate over all its values (which produced events inconsistent with the evidence). Yield the event as-is for such variables. Verified: events no longer violate the evidence, and test_probability4e still passes (22).
1 parent e88a514 commit b536e6d

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎probability4e.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,12 @@ def all_events(variables, bn, e):
591591
else:
592592
X, rest = variables[0], variables[1:]
593593
for e1 in all_events(rest, bn, e):
594-
for x in bn.variable_values(X):
595-
yield extend(e1, X, x)
596-
594+
if X in e:
595+
yield e1
596+
else:
597+
for x in bn.variable_values(X):
598+
yield extend(e1, X, x)
599+
597600

598601
# ______________________________________________________________________________
599602
# 13.3.4 Clustering algorithms

0 commit comments

Comments
 (0)