Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: fix equation pickling #2490

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading