Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
24067: Call sympy_init() at sympy import
Browse files Browse the repository at this point in the history
  • Loading branch information
rwst authored and jdemeyer committed Nov 19, 2017
1 parent 92f95ce commit a97c32f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion build/pkgs/sympy/package-version.txt
@@ -1 +1 @@
1.1.1
1.1.1.p0
12 changes: 12 additions & 0 deletions build/pkgs/sympy/patches/init-conversion.patch
@@ -0,0 +1,12 @@
diff --git a/sympy/__init__.py b/sympy/__init__.py
index 0c52a7512..35f088e58 100644
--- a/sympy/__init__.py
+++ b/sympy/__init__.py
@@ -90,3 +90,7 @@ def __sympy_debug():
#import abc

from .deprecated import *
+
+from sage.interfaces.sympy import sympy_init
+sympy_init()
+
21 changes: 7 additions & 14 deletions src/sage/interfaces/sympy.py
@@ -1,9 +1,8 @@
"""
SymPy --> Sage conversion
The file consists of ``_sage_()`` methods that are added lazily to
the respective SymPy objects. Any call of the ``_sympy_()`` method
of a symbolic expression will trigger the addition. See
The file consists of ``_sage_()`` methods that are added lazily with
any SymPy import to the respective SymPy objects. See
:class:`sage.symbolic.expression_conversion.SymPyConverter` for the
conversion to SymPy.
Expand Down Expand Up @@ -634,23 +633,17 @@ def sympy_init():
Add ``_sage_()`` methods to SymPy objects where needed.
This gets called with every call to ``Expression._sympy_()``
so there is only need to call it if you bypass ``_sympy_()`` to
create SymPy objects. Note that SymPy objects have ``_sage_()``
methods hard installed but having them inside Sage as
one file makes them easier to maintain for Sage developers.
and with any SymPy import so there is no need to call yourself.
Note that many SymPy objects have ``_sage_()`` methods hard installed
but having them inside Sage as one file makes it easier for Sage
developers to maintain and test them.
EXAMPLES::
sage: from sage.interfaces.sympy import sympy_init
sage: from sympy import Symbol, Abs
sage: sympy_init()
sage: assert abs(x) == Abs(Symbol('x'))._sage_()
"""
from sympy import Add
if Add._sage_ == _sympysage_add:
return

from sympy import Mul, Pow, Symbol
from sympy import Add, Mul, Pow, Symbol
from sympy.core.function import (Function, AppliedUndef, Derivative)
from sympy.core.numbers import (Float, Integer, Rational, Infinity,
NegativeInfinity, ComplexInfinity, Exp1, Pi, GoldenRatio,
Expand Down
4 changes: 0 additions & 4 deletions src/sage/symbolic/expression_conversions.py
Expand Up @@ -684,10 +684,6 @@ class SympyConverter(Converter):
x + I
"""
def __init__(self):
from sage.interfaces.sympy import sympy_init
sympy_init()

def pyobject(self, ex, obj):
"""
EXAMPLES::
Expand Down

0 comments on commit a97c32f

Please sign in to comment.