diff --git a/symengine/lib/symengine_wrapper.in.pyx b/symengine/lib/symengine_wrapper.in.pyx index e10d1476..54407ddc 100644 --- a/symengine/lib/symengine_wrapper.in.pyx +++ b/symengine/lib/symengine_wrapper.in.pyx @@ -833,6 +833,9 @@ cdef list vec_pair_to_list(symengine.vec_pair& vec): def load_basic(bytes s): return c2py(symengine.wrapper_loads(s)) +def save_basic(Basic basic): + return symengine.wrapper_dumps(basic) + repr_latex=[False] diff --git a/symengine/tests/test_pickling.py b/symengine/tests/test_pickling.py index 5ae64a75..44b7466c 100644 --- a/symengine/tests/test_pickling.py +++ b/symengine/tests/test_pickling.py @@ -1,4 +1,5 @@ from symengine import symbols, sin, sinh, have_numpy, have_llvm, cos, Symbol +from symengine.lib.symengine_wrapper import load_basic, save_basic from symengine.test_utilities import raises import pickle import unittest @@ -11,6 +12,12 @@ def test_basic(): expr2 = pickle.loads(s) assert expr == expr2 +def test_basic_direct(): + x, y, z = symbols('x y z') + expr = sin(cos(x + y)/z)**2 + s = save_basic(expr) + expr2 = load_basic(s) + assert expr == expr2 class MySymbolBase(Symbol): def __init__(self, name, attr):