Skip to content

Commit

Permalink
Fix domain pickle
Browse files Browse the repository at this point in the history
  • Loading branch information
tehrengruber committed Feb 14, 2025
1 parent 83985b2 commit 4dbac3b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/gt4py/next/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,12 @@ def replace(self, index: int | Dimension, *named_ranges: NamedRange) -> Domain:

return Domain(dims=dims, ranges=ranges)

def __getstate__(self):
state = self.__dict__.copy()
# remove cached property
state.pop("slice_at", None)
return state


FiniteDomain: TypeAlias = Domain[FiniteUnitRange]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pickle

from gt4py.next import common

I = common.Dimension("I")
J = common.Dimension("J")

def test_domain_pickle_after_slice():
domain = common.domain(((I, (2, 4)), (J, (3, 5))))
# use slice_at to populate cached property
domain.slice_at[2:5, 5:7]

pickle.dumps(domain)

0 comments on commit 4dbac3b

Please sign in to comment.