diff options
author | Cathy Yeh <cathy@driver.xyz> | 2017-11-20 17:05:37 -0800 |
---|---|---|
committer | Cathy Yeh <cathy@driver.xyz> | 2017-11-21 13:18:34 -0800 |
commit | d166e36eaf5803af035e444628c67701322b0eb6 (patch) | |
tree | 3e715d2ab34ce447222ccfa11bcde31065faae26 /beliefs/factors/BernoulliOrCPD.py | |
parent | 71e384a741e52f94882b14062a3dc10e5f391533 (diff) | |
download | beliefs-d166e36eaf5803af035e444628c67701322b0eb6.tar.gz beliefs-d166e36eaf5803af035e444628c67701322b0eb6.tar.bz2 beliefs-d166e36eaf5803af035e444628c67701322b0eb6.zip |
refactor msg passing methods to BeliefUpdateNodeModel from BayesianModel
Diffstat (limited to 'beliefs/factors/BernoulliOrCPD.py')
-rw-r--r-- | beliefs/factors/BernoulliOrCPD.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/beliefs/factors/BernoulliOrCPD.py b/beliefs/factors/BernoulliOrCPD.py index e4fcbf1..2c6a31e 100644 --- a/beliefs/factors/BernoulliOrCPD.py +++ b/beliefs/factors/BernoulliOrCPD.py @@ -10,17 +10,22 @@ class BernoulliOrCPD(TabularCPD): If at least one of the variable's parents is True, then the variable is True, and False otherwise. """ - def __init__(self, variable, parents=set()): + def __init__(self, variable, parents=[]): + """ + Args: + variable: int or string + parents: optional, list of int and/or strings + """ super().__init__(variable=variable, variable_card=2, parents=parents, parents_card=[2]*len(parents), - values=None) - self._values = None + values=[]) + self._values = [] @property def values(self): - if self._values is None: + if not any(self._values): self._values = self._build_kwise_values_array(len(self.variables)) self._values = self._values.reshape(self.cardinality) return self._values |