Skip to content

Commit

Permalink
make DataWrapper hash stable
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasdiener committed Sep 18, 2023
1 parent df96738 commit 8b8e66f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pytato/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1675,10 +1675,17 @@ def _is_eq_valid(self) -> bool:
# and valid by returning True
return True

@memoize_method
def __hash__(self) -> int:
# It would be better to hash the data, but we have no way of getting to
# it.
return id(self)
import hashlib

if hasattr(self.data, "get"):
d = self.data.get()
else:
d = self.data

return hash((hashlib.sha256(d).hexdigest(), self._shape,
self.axes, Taggable.__hash__(self)))

@property
def shape(self) -> ShapeType:
Expand Down

0 comments on commit 8b8e66f

Please sign in to comment.