Skip to content

Commit

Permalink
Fix Hasher
Browse files Browse the repository at this point in the history
  • Loading branch information
ElliottKasoar committed Jan 10, 2025
1 parent 35f597b commit 3ce4215
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions abcd/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@


class Hasher(object):
def __init__(self, method=md5()):
self.method = method
def __init__(self, method=md5):
self.method = method()

def update(self, value):

Expand Down Expand Up @@ -273,26 +273,25 @@ def pre_save(self):
self["username"] = getpass.getuser()

if not self.get("uploaded"):
self["uploaded"] = datetime.datetime.utcnow()
self["uploaded"] = datetime.datetime.now(datetime.timezone.utc)

self["modified"] = datetime.datetime.utcnow()
self["modified"] = datetime.datetime.now(datetime.timezone.utc)

m = Hasher()
hasher = Hasher()

for key in ("numbers", "positions", "cell", "pbc"):
m.update(self[key])
hasher.update(self[key])

self.derived_keys.append("hash_structure")
self["hash_structure"] = m()
self["hash_structure"] = hasher()

m = Hasher()
for key in self.arrays_keys:
m.update(self[key])
hasher.update(self[key])
for key in self.info_keys:
m.update(self[key])
hasher.update(self[key])

self.derived_keys.append("hash")
self["hash"] = m()
self["hash"] = hasher()


if __name__ == "__main__":
Expand Down

0 comments on commit 3ce4215

Please sign in to comment.