From 96c9380a040bfd3a57bd7aa3db96b5f99a561396 Mon Sep 17 00:00:00 2001 From: Matt McDermott Date: Sun, 25 Feb 2024 12:30:04 -0800 Subject: [PATCH] Fix bug in `ExperimentalReferenceEntry`; was not comparing equality --- src/rxn_network/entries/experimental.py | 6 +++++- src/rxn_network/reactions/reaction_set.py | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rxn_network/entries/experimental.py b/src/rxn_network/entries/experimental.py index 4b86ecbc..8696092b 100644 --- a/src/rxn_network/entries/experimental.py +++ b/src/rxn_network/entries/experimental.py @@ -2,6 +2,7 @@ from __future__ import annotations import hashlib +import math from typing import TYPE_CHECKING from monty.json import MontyDecoder @@ -196,11 +197,14 @@ def __repr__(self) -> str: return "\n".join(output) def __eq__(self, other) -> bool: + """Note: the value of the energy correction must be compared rather than + the object due to equality checking in EnergyAdjustment. + """ if isinstance(other, self.__class__): return ( (self.composition.reduced_formula == other.composition.reduced_formula) and (self.temperature == other.temperature) - and (set(self.energy_adjustments) == set(other.energy_adjustments)) + and math.isclose(self.correction_per_atom, other.correction_per_atom) ) return False diff --git a/src/rxn_network/reactions/reaction_set.py b/src/rxn_network/reactions/reaction_set.py index 303e58fc..f7ac9209 100644 --- a/src/rxn_network/reactions/reaction_set.py +++ b/src/rxn_network/reactions/reaction_set.py @@ -308,6 +308,7 @@ def add_rxn_set(self, rxn_set: ReactionSet) -> ReactionSet: """ if self.entries != rxn_set.entries: raise ValueError("Reaction sets must have identical entries property to combine.") + open_elem = self.open_elem chempot = self.chempot