Skip to content

Issues pickling sympy.Function('f') #190

@asmeurer

Description

@asmeurer

We have a test failure in our SymPy test suite from cloudpickle. I have bisected it to the cloudpickle commit aec80d2

The failure is described at sympy/sympy#15116

The basic failure is this:

>>> import cloudpickle
>>> from sympy import Function
>>> f = Function('f')
>>> f1 = cloudpickle.loads(cloudpickle.dumps(f))
>>> f.__dict__['_prop_handler']
{'commutative': <function Function._eval_is_commutative at 0x1121f27b8>, 'negative': <function Expr._eval_is_negative at 0x112112d08>, 'positive': <function Expr._eval_is_positive at 0x112112c80>, 'complex': <function Function._eval_is_complex at 0x1121f2840>}
>>> f1.__dict__['_prop_handler']
{'commutative': <function Function._eval_is_commutative at 0x1130a7d08>, 'negative': <function Expr._eval_is_negative at 0x1130a7e18>, 'positive': <function Expr._eval_is_positive at 0x11309bbf8>, 'complex': <function Function._eval_is_complex at 0x1130aae18>}
>>> from sympy import Expr
>>> Expr._eval_is_negative
<function Expr._eval_is_negative at 0x112112d08>

The SymPy test tests that all the attributes are the same, and fails because cloudpickle creates new instances of the Expr methods.

I'm not clear if this affects functionality or not.

CC @ssanderson

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions