Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
shervin86 committed Apr 3, 2024
1 parent ce63a91 commit b80a536
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libpyvinyl/BaseCalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,11 @@ def __call__(self, parameters=None, **kwargs):
return new

def __hash__(self):
"""Hashing capability for a Calculator
Parameters are removed when calculating the hash.
The hash of the parameters can be accessed by hash(calc.parameters).
This logic allows to decouple the changes in the calculator from changes in the values of the parameters
"""
a = dill.copy(self)
a.init_parameters()
return int.from_bytes(hashlib.sha256(dill.dumps(a)).digest(), "big")
Expand Down

0 comments on commit b80a536

Please sign in to comment.