---
sympy/functions/elementary/piecewise.py | 7 +++++++
sympy/utilities/tests/test_pickling.py | 3 +--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/sympy/functions/elementary/piecewise.py b/sympy/functions/elementary/piecewise.py
index 5a98ce6..db83072 100644
--- a/sympy/functions/elementary/piecewise.py
+++ b/sympy/functions/elementary/piecewise.py
@@ -78,6 +78,13 @@ def __new__(cls, *args, **options):
else:
return r
+ def __getnewargs__(self):
+ # Convert ExprCondPair objects to tuples.
+ args = []
+ for expr, condition in self.args:
+ args.append((expr, condition))
+ return tuple(args)
+
@classmethod
def canonize(cls, *args):
# Check for situations where we can evaluate the Piecewise object.
diff --git a/sympy/utilities/tests/test_pickling.py b/sympy/utilities/tests/test_pickling.py
index 86b55c3..2e08a17 100644
--- a/sympy/utilities/tests/test_pickling.py
+++ b/sympy/utilities/tests/test_pickling.py
@@ -161,8 +161,7 @@ def test_functions():
min_, atan2, polygamma, hermite, legendre, uppergamma)
x, y, z = symbols("x y z")
others = (chebyshevt_root, chebyshevu_root, Eijk(x, y, z),
- # XXX: Piecewise pickling doesn't work:
- #Piecewise( (0, x<-1), (x**2, x<=1), (x**3, True)),
+ Piecewise( (0, x<-1), (x**2, x<=1), (x**3, True)),
assoc_legendre)
for a in zero_var:
check(a)
--
1.6.0.4.1060.g9433b
Thanks for the review. I'll add the docstring for it.
Ondrej