Skip to content

Commit

Permalink
added eq and safe hash to ComplexEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamBanham committed Feb 6, 2025
1 parent b60087a commit 1acaebf
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions pmkoalas/complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ class ComplexEvent():
def __init__(self, activity:str, data:Mapping[str,object]) -> None:
self._act = activity
self._map = deepcopy(data)
self._hash = hash(
tuple(
[self._act,]+
[hash(tuple([key,val])) for key,val
in self._map.items()]
)
)

def activity(self) -> str:
""" the process activity denoted by this event """
Expand Down Expand Up @@ -71,7 +64,18 @@ def __repr__(self) -> str:
return repr

def __hash__(self) -> int:
return self._hash
return hash(
tuple(
[self._act,]+
[hash(tuple([key,val])) for key,val
in self._map.items()]
)
)

def __eq__(self, value):
if (isinstance(value, ComplexEvent)):
return self.activity() == value.activity() \
and self.data() == value.data()

class ComplexTrace():
"""
Expand Down

0 comments on commit 1acaebf

Please sign in to comment.