Skip to content

Commit

Permalink
Fix bug in ExperimentalReferenceEntry; was not comparing equality
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmcdermott committed Feb 25, 2024
1 parent a5949a7 commit 96c9380
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/rxn_network/entries/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import annotations

import hashlib
import math
from typing import TYPE_CHECKING

from monty.json import MontyDecoder
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/rxn_network/reactions/reaction_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 96c9380

Please sign in to comment.