c676395da1a5ca321ba75f6a8025eefa4b99483e,pgmpy/models/ClusterGraph.py,ClusterGraph,get_cardinality,#ClusterGraph#Any#,211

Before Change


        for factor in self.factors:
            for variable, cardinality in zip(factor.scope(), factor.cardinality):
                cardinalities[variable] = cardinality
        if check_cardinality and len(set((x for clique in self.nodes() for x in clique))) != len(cardinalities):
            raise ValueError("Factors for all the variables not defined.")
        return cardinalities

After Change


        >>> student.get_cardinality(node="Alice")
        2
        
        if node:
            for factor in self.factors:
                for variable, cardinality in zip(factor.scope(), factor.cardinality):
                    if node == variable:
                        return cardinality

        else:
	        cardinalities = defaultdict(int)
	        for factor in self.factors:
	            for variable, cardinality in zip(factor.scope(), factor.cardinality):
	                cardinalities[variable] = cardinality
	        return cardinalities

    def get_partition_function(self):
        r
        Returns the partition function for a given undirected graph.
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: pgmpy/pgmpy
Commit Name: c676395da1a5ca321ba75f6a8025eefa4b99483e
Time: 2017-10-04
Author: lohani.ayush01@gmail.com
File Name: pgmpy/models/ClusterGraph.py
Class Name: ClusterGraph
Method Name: get_cardinality


Project Name: pgmpy/pgmpy
Commit Name: ca25da7c55ba436ab557410d5f2e2e9b557d2840
Time: 2015-03-02
Author: abinash.panda.ece10@itbhu.ac.in
File Name: pgmpy/models/MarkovModel.py
Class Name: MarkovModel
Method Name: to_junction_tree


Project Name: pgmpy/pgmpy
Commit Name: 9340e62be9d010c5db6724c27589d885fa08b27e
Time: 2017-10-04
Author: lohani.ayush01@gmail.com
File Name: pgmpy/models/FactorGraph.py
Class Name: FactorGraph
Method Name: get_cardinality