I have a class called Factor
in the Factor.py
module ( https://github.com/pgmpy/pgmpy/blob/dev/pgmpy/factors/Factor.py ), as well as a function called factor_product
in Factor.py
like:
def factor_product(*args): if not all(isinstance(phi, Factor) for phi in args): raise TypeError("Input parameters must be factors") return functools.reduce(lambda phi1, phi2: _bivar_factor_operation(phi1, phi2, operation='M'), args)
Now, even if I pass the Factor
function to a function, it throws a TypeError
. A few lines from the debugger with a breakpoint set above the if statement:
(Pdb) args args = (<pgmpy.factors.Factor.Factor object at 0x7fed0faf76a0>, <pgmpy.factors.Factor.Factor object at 0x7fed0faf7da0>) (Pdb) isinstance(args[0], Factor) False (Pdb) type(args[0]) <class 'pgmpy.factors.Factor.Factor'> (Pdb) Factor <class 'pgmpy.factors.Factor.Factor'>
Any idea why this is happening?
source share