pgmpy
pgmpy copied to clipboard
[BUG] `__eq__` method of `LinearGaussianBayesianMethod` returns `True` even for models with different structures
Describe the bug
Even when the structure of two models are different, __eq__ methods always return True if both the models have same CPDs.
To Reproduce
from pgmpy.models import LinearGaussianBayesianNetwork
from pgmpy.factors.continuous import LinearGaussianCPD
# Two models with same CPDs but different structures
model1 = LinearGaussianBayesianNetwork([("x1", "x2"), ("x2", "x3")])
model2 = LinearGaussianBayesianNetwork([("x1", "x2"), ("x1", "x3")]) # This model has a different edge
cpd1 = LinearGaussianCPD("x1", [1], 4)
cpd2 = LinearGaussianCPD("x2", [-5, 0.5], 4, ["x1"])
cpd3 = LinearGaussianCPD("x3", [4, -1], 3, ["x2"])
model1.add_cpds(cpd1, cpd2, cpd3)
model2.add_cpds(cpd1, cpd2, cpd3)
print(model1 == model2)
Expected behavior It should return False.
Additional context The method does compute True or False values for structure, but doesn't do anything about it and False value also just pass.
super().__eq__(other)
@ankurankan Can you please assign me this issue?