Skip to content

Commit

Permalink
Add __hash__ method to Substance class
Browse files Browse the repository at this point in the history
  • Loading branch information
DNIIBOY committed Feb 24, 2024
1 parent 1ef1bf6 commit 22680e2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions chempy/chemistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ def __eq__(self, other):
return False
return True

def __hash__(self) -> int:
return sum(
map(
hash,
(
getattr(self, k)
for k in self.attrs
),
)
)

@property
def charge(self):
"""Convenience property for accessing ``composition[0]``"""
Expand Down

0 comments on commit 22680e2

Please sign in to comment.