Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_sympy_ conversion for BuiltinFunction and CallableSymbolicExpression objects #32130

Closed
mkoeppe opened this issue Jul 5, 2021 · 10 comments
Closed

Comments

@mkoeppe
Copy link
Member

mkoeppe commented Jul 5, 2021

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.

CC: @egourgoulhon @nbruin @kcrisman @EmmanuelCharpentier @mwageringel

Component: symbolics

Author: Matthias Koeppe

Branch/Commit: d9cff76

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/32130

@mkoeppe mkoeppe added this to the sage-9.4 milestone Jul 5, 2021
@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@mkoeppe mkoeppe changed the title _sympy_ method for function objects _sympy_ conversion for BuiltinFunction and CallableSymbolicExpression objects Jul 5, 2021
@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 5, 2021

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 5, 2021

New commits:

d9cff76Function._sympy_, SympyConverter.__call__: New

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 5, 2021

Author: Matthias Koeppe

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 5, 2021

Commit: d9cff76

@tscrim
Copy link
Collaborator

tscrim commented Jul 12, 2021

comment:7

LGTM.

@tscrim
Copy link
Collaborator

tscrim commented Jul 12, 2021

Reviewer: Travis Scrimshaw

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 12, 2021

comment:8

Thanks!

@vbraun
Copy link
Member

vbraun commented Jul 24, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants