I have a class named Factor
in the module Factor.py
(https://github.com/pgmpy/pgmpy/blob/dev/pgmpy/factors/Factor.py) and also have function named factor_product
in Factor.py
as:
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 if I even pass instances of Factor
to the function, it still throws TypeError
. A few lines from the debugger with breakpoint set just 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 ?