Skip to content

Commit

Permalink
misc: fix EnrichedTuple rebuilding
Browse files Browse the repository at this point in the history
  • Loading branch information
enwask committed Jul 19, 2024
1 parent ea94a0f commit 6d74bf6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions devito/tools/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class EnrichedTuple(tuple, Pickable):
A tuple with an arbitrary number of additional attributes.
"""

__rkwargs__ = ('getters',)

def __new__(cls, *items, getters=None, **kwargs):
obj = super().__new__(cls, items)
obj.__dict__.update(kwargs)
Expand Down Expand Up @@ -76,6 +78,11 @@ def __getnewargs_ex__(self):
def get(self, key, val=None):
return self._getters.get(key, val)

@cached_property
def getters(self):
# Needed for `Pickable._rebuild`
return list(self._getters)


class ReducerMap(MultiDict):

Expand Down

0 comments on commit 6d74bf6

Please sign in to comment.