Skip to content

Commit

Permalink
Merge pull request #72 from cool-RR/patch-1
Browse files Browse the repository at this point in the history
Fix exception causes in core/macid_base.py
  • Loading branch information
Jamesfox1 authored Sep 17, 2023
2 parents b28c33a + 1723108 commit 3d91e8d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pycid/core/macid_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ def optimal_pure_policies(
decisions = set(decisions)
try:
(agent,) = {self.decision_agent[d] for d in decisions}
except ValueError:
raise ValueError("Decisions not all from the same agent")
except ValueError as e:
raise ValueError("Decisions not all from the same agent") from e

macid = self.copy()
for d in macid.decisions:
Expand Down Expand Up @@ -361,8 +361,8 @@ def impute_random_decision(self, d: str) -> None:
"""Impute a random policy to the given decision node"""
try:
domain = self.model.domain[d]
except KeyError:
raise ValueError(f"can't figure out domain for {d}, did you forget to specify DecisionDomain?")
except KeyError as e:
raise ValueError(f"can't figure out domain for {d}, did you forget to specify " f"DecisionDomain?") from e
else:
self.model[d] = StochasticFunctionCPD(
d, lambda **pv: {outcome: 1 / len(domain) for outcome in domain}, self, domain, label="random_decision"
Expand Down

0 comments on commit 3d91e8d

Please sign in to comment.