Skip to content

Commit

Permalink
Removed hacky hashing.
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahGale committed Sep 12, 2024
1 parent c9fff24 commit b1c2c0e
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions montepy/data_inputs/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,21 +421,5 @@ def validate(self):
f"Material: {self.number} does not have any components defined."
)

def __hash__(self):
"""WARNING: this is a temporary solution to make sets remove duplicate materials.
This should be fixed in the future to avoid issues with object mutation:
<https://eng.lyft.com/hashing-and-equality-in-python-2ea8c738fb9d>
"""
temp_hash = ""
sorted_isotopes = sorted(list(self._material_components.keys()))
for isotope in sorted_isotopes:
temp_hash = hash(
(temp_hash, str(isotope), self._material_components[isotope].fraction)
)
# TODO
return hash((temp_hash, self.number))

def __eq__(self, other):
return hash(self) == hash(other)

0 comments on commit b1c2c0e

Please sign in to comment.