#32130 closed enhancement (fixed)

_sympy_ conversion for BuiltinFunction and CallableSymbolicExpression objects

Reported by: Matthias Köppe Owned by:
Priority: major Milestone: sage-9.4
Component: symbolics Keywords:
Cc: Eric Gourgoulhon, Nils Bruin, Karl-Dieter Crisman, Emmanuel Charpentier, Markus Wageringel Merged in:
Authors: Matthias Koeppe Reviewers: Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: d9cff76 (Commits, GitHub, GitLab) Commit: d9cff76316fec2da8e4f9ae20eabebef5b4eeb4b
Dependencies: Stopgaps:

Status badges

Description (last modified by Matthias Köppe)

Currently we have:

sage: from sympy import sympify
sage: sympify(sin(x))
sin(x)
sage: 
sage: sympify(sin)
SymPyDeprecationWarning: 

String fallback in sympify has been deprecated since SymPy 1.6. Use
sympify(str(obj)) or sympy.core.sympify.converter or obj._sympy_
instead. 

We should fix this by providing functions with a _sympy_ method that implements the same conversion as SympyConverter.composition.

Also, converting CallableSymbolicExpression to sympy forgets about the formal arguments:

sage: from sympy import sympify
sage: f(x, y) = x^2 + y^2; f
(x, y) |--> x^2 + y^2
sage: sympify(f)
x**2 + y**2

We change it to return a SymPy Lambda instead.

Change History (9)

comment:1 Changed 17 months ago by Matthias Köppe

Description: modified (diff)

comment:2 Changed 17 months ago by Matthias Köppe

Description: modified (diff)
Summary: _sympy_ method for function objects_sympy_ conversion for BuiltinFunction and CallableSymbolicExpression objects

comment:3 Changed 17 months ago by Matthias Köppe

Branch: u/mkoeppe/_sympy__conversion_for_builtinfunction_and_callablesymbolicexpression_objects

comment:4 Changed 17 months ago by Matthias Köppe

Authors: Matthias Koeppe
Commit: d9cff76316fec2da8e4f9ae20eabebef5b4eeb4b
Status: newneeds_review

New commits:

d9cff76Function._sympy_, SympyConverter.__call__: New

comment:5 Changed 17 months ago by Matthias Köppe

Cc: Nils Bruin Karl-Dieter Crisman added

comment:6 Changed 17 months ago by Matthias Köppe

Cc: Emmanuel Charpentier Markus Wageringel added

comment:7 Changed 17 months ago by Travis Scrimshaw

Reviewers: Travis Scrimshaw
Status: needs_reviewpositive_review

LGTM.

comment:8 Changed 17 months ago by Matthias Köppe

Thanks!

comment:9 Changed 17 months ago by Volker Braun

Branch: u/mkoeppe/_sympy__conversion_for_builtinfunction_and_callablesymbolicexpression_objectsd9cff76316fec2da8e4f9ae20eabebef5b4eeb4b
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.