@@ -15,10 +15,159 @@ _pyimport(a) = PyCall.pyimport(a)
1515_pyimport_conda (a,b) = PyCall. pyimport_conda (a, b)
1616_pyobject (x) = PyCall. PyObject (x)
1717_pytype_mapping (typ,a) = PyCall. pytype_mapping (typ, a)
18- const _pybuiltin = PyCall. builtin
1918
20- core_src_path = joinpath (pathof (SymPy. SymPyCore), " ../../src/SymPy" )
21- include (joinpath (core_src_path, " sympy.jl" ))
19+ # for 1.6, we can't pass in _pybuiltin so we just
20+ # paste in here sympy.jl and modify.
21+ # not DRY!
22+ # core_src_path = joinpath(pathof(SymPy.SymPyCore), "../../src/SymPy")
23+ # include(joinpath(core_src_path, "sympy.jl"))
24+ # # Common code
25+
26+ using LinearAlgebra
27+ import SpecialFunctions
28+ import CommonEq
29+ import CommonSolve
30+
31+ # # XXX This should be in a file in SymPyCore...
32+ #=
33+ Several functions are exported
34+
35+ * generic functions in base `Julia` having a `sympy` counterpart have
36+ methods defined to dispatch on the first argument. (Basically,
37+ `Base.sin(x::Sym) = \uparrow(_sympy_.sin(\downarrow(x))`.) These are
38+ defined in the `generic_methods` list in `SymPyCore` and read in via
39+ the package once a Python bridge is in place.
40+
41+ * Some object methods, such as `ex.subs(...)` have exported functions
42+ that use the `Julian` order `subs(ex, ...)`. All object methods
43+ should be callable using the python syntax `obj.method(...)`.
44+
45+ * Functions in `sympy` that are foundational (e.g., `simplify`) have
46+ methods created dispatch on the first argument being symbolic
47+ (typically type `Sym`). These are exported. Other functions, e.g.,
48+ `trigsimp` may be called via `sympy.trigsimp(...)`.
49+ =#
50+
51+ # # import/exports
52+ import SymPyCore: ↑ , ↓ , ↓ ₖ
53+ import SymPyCore: SymbolicObject, Sym, SymFunction
54+ import SymPyCore: symbols, free_symbols
55+ import SymPyCore: simplify, expand, together, apart, factor, cancel
56+ import SymPyCore: solve, dsolve, nsolve, linsolve, nonlinsolve, solveset
57+ import SymPyCore: subs, lambdify, simplify
58+ import SymPyCore: ask, doit
59+ import SymPyCore: N
60+ import SymPyCore: limit, diff, integrate, Differential, Heaviside
61+ import SymPyCore: rhs, lhs
62+ import SymPyCore: Wild, Permutation, PermutationGroup
63+ import SymPyCore: ∨ , ∧ , ¬ # infix logical operators
64+
65+ # more exports defined in SymPyCore/src/gen_methods_sympy
66+ export Sym, SymFunction
67+ export sympy, PI, E, IM, oo, zoo
68+ export @syms , sympify, symbols, free_symbols
69+ export simplify, expand, together, apart, factor, cancel
70+ export solve, dsolve, nsolve, linsolve, nonlinsolve, solveset
71+ export real_roots, nroots # roots
72+ export sign # ,degree
73+ export series, summation, hessian
74+ export subs, lambdify
75+ export ask, doit, rewrite
76+ export N
77+ export limit, diff, integrate, Differential, Heaviside
78+ export rhs, lhs
79+ export Wild # , cse
80+ export Permutation, PermutationGroup
81+ export ∨ , ∧ , ¬
82+ export 𝑄, 𝑆, Introspection
83+
84+ export ↓ , ↑
85+
86+ # emacs and indent; this goes last
87+ import SymPyCore: Lt, ≪ , Le, ≦ , Eq, ⩵ , Ne, ≶ , ≷ , Ge, ≫ , Gt, ≧
88+ export Lt, ≪ , Le, ≦ , Eq, ⩵ , Ne, ≶ , ≷ , Ge, ≫ , Gt, ≧
89+
90+
91+
92+ # exported symbols and their python counterparts
93+ const _sympy_ = _pynull ()
94+ const sympy = Sym (_sympy_)
95+
96+ const _combinatorics_ = _pynull ()
97+ const combinatorics = Sym (_combinatorics_)
98+
99+ const _PI_ = _pynull ()
100+ const PI = Sym (_PI_)
101+
102+ const _E_ = _pynull ()
103+ const E = Sym (_E_)
104+
105+ const _IM_ = _pynull ()
106+ const IM = Sym (_IM_)
107+
108+ const _oo_ = _pynull ()
109+ const oo = Sym (_oo_)
110+
111+ const _zoo_ = _pynull ()
112+ const zoo = Sym (_zoo_)
113+
114+ Base. @deprecate_binding TRUE Sym (true )
115+ Base. @deprecate_binding FALSE Sym (false )
116+
117+ const _𝑄_ = _pynull ()
118+ const 𝑄 = Sym (_𝑄_)
119+
120+ const _𝑆_ = _pynull ()
121+ const 𝑆 = Sym (_𝑆_)
122+
123+ # ugly, but needed to speed up python_connection
124+ const _pyset_ = _pynull ()
125+ const _pytuple_ = _pynull ()
126+ const _pylist_ = _pynull ()
127+ const _pydict_ = _pynull ()
128+ const _bool_ = _pynull ()
129+ const _types_ = _pynull ()
130+ const _ModuleType_ = _pynull ()
131+ const _FiniteSet_ = _pynull ()
132+ const _MutableDenseMatrix_ = _pynull ()
133+
134+ function __init__ ()
135+
136+ # # Define sympy, mpmath, ...
137+ _copy! (_sympy_, _pyimport_conda (" sympy" , " sympy" ))
138+ _copy! (_combinatorics_, _pyimport_conda (" sympy.combinatorics" , " sympy" ))
139+
140+ _copy! (_PI_, _sympy_. pi )
141+ _copy! (_E_, _sympy_. E)
142+ _copy! (_IM_, _sympy_. I)
143+ _copy! (_oo_, _sympy_. oo)
144+ _copy! (_zoo_, _sympy_. zoo)
145+ _copy! (_𝑆_, _sympy_. S)
146+ _copy! (_𝑄_, _sympy_. Q)
147+
148+ # ugly, avoids allocation in PyCall
149+ _pybuiltin = PyCall. builtin # <-- needed with 1.6 + SymPy
150+ _copy! (_pyset_, getproperty (_pybuiltin, :set ))
151+ _copy! (_pytuple_, getproperty (_pybuiltin, :tuple ))
152+ _copy! (_pylist_, getproperty (_pybuiltin, :list ))
153+ _copy! (_pydict_, getproperty (_pybuiltin, :dict ))
154+ _copy! (_bool_, getproperty (_pybuiltin, :bool ))
155+ _copy! (_types_, _pyimport_conda (" types" , " types" ))
156+ _copy! (_ModuleType_, getproperty (_types_, :ModuleType ))
157+ _copy! (_FiniteSet_, _sympy_. FiniteSet)
158+ _copy! (_MutableDenseMatrix_, _sympy_. MutableDenseMatrix)
159+
160+
161+ end
162+
163+
164+ # includes
165+ core_src_path = joinpath (pathof (SymPyCore), " ../../src/SymPy" )
166+ include (joinpath (core_src_path, " constructors_sympy.jl" ))
167+ include (joinpath (core_src_path, " gen_methods_sympy.jl" ))
168+ include (joinpath (core_src_path, " additional_methods_sympy.jl" ))
169+ include (joinpath (core_src_path, " show_sympy.jl" ))
170+
22171
23172include (" python_connection.jl" )
24173
0 commit comments