[PATCH 2/2] Do not test pickling for regular python functions (#1259)

1 view
Skip to first unread message

Ondrej Certik

unread,
Jan 11, 2009, 9:58:02 PM1/11/09
to sympy-...@googlegroups.com, Ondrej Certik
E.g. we deleted sqrt, assoc_legendre, Ylm and Zlm, because those are just
Python functions, that return some other symbolic expression. This was working
in python2.5 and later, but failed in python2.4. Since it was useless to test
these, we just removed them.

Signed-off-by: Ondrej Certik <ond...@certik.cz>
---
sympy/utilities/tests/test_pickling.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sympy/utilities/tests/test_pickling.py b/sympy/utilities/tests/test_pickling.py
index b30611b..86b55c3 100644
--- a/sympy/utilities/tests/test_pickling.py
+++ b/sympy/utilities/tests/test_pickling.py
@@ -156,14 +156,14 @@ def test_functions():
sign, arg, asin, DiracDelta, re, abs, sinh, cos, cot, acos, acot,
gamma, bell, harmonic, LambertW, zeta, log, Factorial, asinh,
acoth, cosh, dirichlet_eta, loggamma, erf, ceiling, im, fibonacci,
- conjugate, tan, floor, atanh, sqrt, sin, atan, lucas, exp)
+ conjugate, tan, floor, atanh, sin, atan, lucas, exp)
two_var = (rf, ff, lowergamma, chebyshevu, chebyshevt, binomial, max_,
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)),
- assoc_legendre, Ylm, Zlm)
+ assoc_legendre)
for a in zero_var:
check(a)
for cls in one_var:
--
1.6.0.4.1060.g9433b

Ondrej Certik

unread,
Jan 11, 2009, 9:58:03 PM1/11/09
to sympy-...@googlegroups.com, Ondrej Certik
Previously the sympy.function module was imported and dynamicaly queried for
all symbols and then all of them were tested. This was not robust, so we now
import and test everything explicitly. In the next patch, we remove the
problematic tests, so that things work in python2.4.

Signed-off-by: Ondrej Certik <ond...@certik.cz>
---

sympy/utilities/tests/test_pickling.py | 48 ++++++++++++++++++++++++-------
1 files changed, 37 insertions(+), 11 deletions(-)

diff --git a/sympy/utilities/tests/test_pickling.py b/sympy/utilities/tests/test_pickling.py
index 9a94dbc..b30611b 100644
--- a/sympy/utilities/tests/test_pickling.py
+++ b/sympy/utilities/tests/test_pickling.py
@@ -23,6 +23,8 @@
from sympy.core.cache import Memoizer
#from sympy.core.ast_parser import SymPyParser, SymPyTransformer

+from sympy import symbols
+

def check(a):
""" Check that pickling and copying round-trips.
@@ -137,19 +139,43 @@ def test_core_cache():


#================== functions ===================
-# XXX: These tests are not complete.
-from sympy import functions
+from sympy.functions import (Piecewise, lowergamma, acosh,
+ chebyshevu, chebyshevt, ln, chebyshevt_root, Binomial, legendre,
+ Heaviside, Dij, factorial, bernoulli, coth, tanh, assoc_legendre, sign,
+ arg, asin, DiracDelta, re, rf, abs, uppergamma, binomial, sinh, Ylm,
+ oo, cos, cot, acos, acot, gamma, bell, hermite, harmonic,
+ LambertW, zeta, log, Factorial, pi, asinh, acoth, Zlm,
+ cosh, dirichlet_eta, Eijk, loggamma, erf, max_, ceiling, im, fibonacci,
+ conjugate, tan, chebyshevu_root, floor, atanh, nan, sqrt, zoo, min_,
+ RisingFactorial, sin, E, atan, I, ff, FallingFactorial, lucas, atan2,
+ polygamma, exp)

def test_functions():
- x = Symbol("x")
- for name, cls in vars(functions).iteritems():
- if hasattr(cls, "__class__") and not cls.__class__ is types.ModuleType and not name[0]=="_":
- check(cls)
- try:
- c = cls(x)
- except:
- continue
- check(c)
+ zero_var = (pi, oo, nan, zoo, E, I)
+ one_var = (acosh, ln, Heaviside, Dij, factorial, bernoulli, coth, tanh,
+ sign, arg, asin, DiracDelta, re, abs, sinh, cos, cot, acos, acot,
+ gamma, bell, harmonic, LambertW, zeta, log, Factorial, asinh,
+ acoth, cosh, dirichlet_eta, loggamma, erf, ceiling, im, fibonacci,
+ conjugate, tan, floor, atanh, sqrt, sin, atan, lucas, exp)
+ two_var = (rf, ff, lowergamma, chebyshevu, chebyshevt, binomial, max_,
+ 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)),
+ assoc_legendre, Ylm, Zlm)
+ for a in zero_var:
+ check(a)
+ for cls in one_var:
+ check(cls)
+ c = cls(x)
+ check(c)
+ for cls in two_var:
+ check(cls)
+ c = cls(x, y)
+ check(c)
+ for cls in others:
+ check(cls)

#================== geometry ====================
from sympy.geometry.entity import GeometryEntity
--
1.6.0.4.1060.g9433b

Reply all
Reply to author
Forward
0 new messages