Skip to content

Commit

Permalink
Merge pull request #2490 from devitocodes/pickel-eq
Browse files Browse the repository at this point in the history
api: fix equation pickling
  • Loading branch information
mloubout authored Nov 18, 2024
2 parents 279f074 + 3bbbe79 commit bedb1a9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions devito/types/equation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import sympy

from devito.deprecations import deprecations
from devito.tools import as_tuple, frozendict
from devito.tools import as_tuple, frozendict, Pickable
from devito.types.lazy import Evaluable

__all__ = ['Eq', 'Inc', 'ReduceMax', 'ReduceMin']


class Eq(sympy.Eq, Evaluable):
class Eq(sympy.Eq, Evaluable, Pickable):

"""
An equal relation between two objects, the left-hand side and the
Expand Down
18 changes: 18 additions & 0 deletions tests/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,24 @@ def test_derivative(self, pickle, transpose, side, deriv_order,
assert new_dfdx.method == dfdx.method
assert new_dfdx.weights == dfdx.weights

def test_equation(self, pickle):
grid = Grid(shape=(3,))
x = grid.dimensions[0]
f = Function(name='f', grid=grid)

# Some implicit dim
xs = ConditionalDimension(name='xs', parent=x, factor=4)

eq = Eq(f, f+1, implicit_dims=xs)

pkl_eq = pickle0.dumps(eq)
new_eq = pickle0.loads(pkl_eq)

assert new_eq.lhs.name == f.name
assert str(new_eq.rhs) == 'f(x) + 1'
assert new_eq.implicit_dims[0].name == 'xs'
assert new_eq.implicit_dims[0].factor.data == 4


class TestAdvanced:

Expand Down

0 comments on commit bedb1a9

Please sign in to comment.