This class is constructed with a :doc:`DiscreteBayesianNetwork ` instance as argument. First, it takes the input itself and stores it in the *bn* attribute. Then, it transforms the information of each of these nodes from standard discrete CPD form into a :doc:`Table
(self, bn)
| 39 | ''' |
| 40 | |
| 41 | def __init__(self, bn): |
| 42 | ''' |
| 43 | This class is constructed with a :doc:`DiscreteBayesianNetwork <discretebayesiannetwork>` instance as argument. First, it takes the input itself and stores it in the *bn* attribute. Then, it transforms the information of each of these nodes from standard discrete CPD form into a :doc:`TableCPDFactor <tablecpdfactor>` isntance and stores the instances in an array in the attribute *originalfactorlist*. Finally, it makes a copy of this list to work with and stores it in *factorlist*. |
| 44 | |
| 45 | ''' |
| 46 | assert hasattr(bn, "V") and hasattr(bn, "E") and hasattr(bn, "Vdata"), \ |
| 47 | "Input must be a DiscreteBayesianNetwork instance." |
| 48 | |
| 49 | self.bn = bn |
| 50 | '''The Bayesian network used as argument at instantiation.''' |
| 51 | self.originalfactorlist = [] |
| 52 | '''A list of :doc:`TableCPDFactor <tablecpdfactor>` instances, one per node.''' |
| 53 | for vertex in bn.V: |
| 54 | factor = TableCPDFactor(vertex, bn) |
| 55 | self.originalfactorlist.append(factor) |
| 56 | self.factorlist = copy.deepcopy(self.originalfactorlist) |
| 57 | '''A working copy of *originalfactorlist*.''' |
| 58 | |
| 59 | assert self.factorlist, "Factor list not properly loaded, check for an incomplete class instance as input." |
| 60 | |
| 61 | def refresh(self): |
| 62 | ''' |
nothing calls this directly
no test coverage detected