in neuron_explainer/explanations/explanations.py [0:0]
def __eq__(self, other: Any) -> bool:
if not isinstance(other, ScoredSequenceSimulation):
return False
if len(self.__dict__.keys()) != len(other.__dict__.keys()):
return False
# Since NaN != NaN in Python, we need to make an exception for this case when checking for equality
# of two ScoredSequenceSimulation objects.
for field_name in self.__dict__.keys():
if field_name not in other.__dict__:
return False
self_val, other_val = self.__dict__[field_name], other.__dict__[field_name]
if self_val != other_val:
if not (
isinstance(self_val, float)
and math.isnan(self_val)
and isinstance(other_val, float)
and math.isnan(other_val)
):
return False
return True