Skip to content

Commit d7610a5

Browse files
authored
Deprecate functions not supported in SymPyCore (#533)
* Deprecate functions not supported in SymPyCore * comment on deprecations
1 parent 0d6a507 commit d7610a5

File tree

14 files changed

+271
-88
lines changed

14 files changed

+271
-88
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "SymPy"
22
uuid = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6"
3-
version = "1.1.14"
3+
version = "1.2.0"
44

55
[deps]
66
CommonEq = "3709ef60-1bee-4518-9f2f-acd86f176c50"

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
[![](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliapy.github.io/SymPy.jl/dev/)
44

55

6+
> **Note**
7+
> `SymPy` is on the move... Well, actually, the `SymPy.jl` package is planned to utilize
8+
> the new [SymPyCore](https://github.com/jverzani/SymPyCore.jl) backend, which is used by [SymPyPythonCall](https://github.com/jverzani/SymPyPythonCall.jl) and (temporarily) by the unregistered [SymPyPyCall](https://github.com/jverzani/SymPyPyCall.jl).
9+
>
10+
> The plan is:
11+
>
12+
> * `v"1.2.0"` will include most all deprecations. See `src/deprecated.jl` for details
13+
>
14+
> * `v"2.0.0"` will be what is currently `SymPyPyCall`. It is expected that most all code will continue to work as is, though if a few of the dustier corners are used, there may need to be some modest adjustments.
15+
616

717
# SymPy Package to bring Python's `SymPy` functionality into `Julia` via `PyCall`
818

src/SymPy.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ include("permutations.jl")
8181
include("plot_recipes.jl")
8282
include("latexify_recipe.jl")
8383

84+
include("deprecated.jl")
8485
##################################################
8586

8687
pynull() = PyCall.PyNULL()
@@ -121,6 +122,7 @@ global False = Sym(pynull())
121122

122123

123124

125+
124126
# Can not actually initiate many things until `sympy` is defined, so not until runtime
125127
function __init__()
126128

@@ -144,7 +146,7 @@ function __init__()
144146
# can't load
145147
end
146148

147-
# pull in alibrary
149+
# pull in a library
148150
copy!(combinatorics, PyCall.pyimport_conda("sympy.combinatorics", "sympy"))
149151

150152

src/constructors.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Examples:
3030
@vars a b real=true
3131
```
3232
!!! Note:
33-
The `@syms` macro is recommended as it has a more flexible syntax
33+
The `@vars` macro is deprecated and will be removed. Use `@syms`.
3434
"""
3535
macro vars(x...)
3636
q = Expr(:block)
@@ -144,6 +144,7 @@ end
144144

145145
## avoid PyObject conversion as possible
146146
Sym(x::T) where {T <: Number} = sympify(x)
147+
Sym(x::Bool) = Sym(PyObject(x))
147148
Sym(x::Rational{T}) where {T} = Sym(numerator(x))/Sym(denominator(x))
148149
function Sym(x::Complex{Bool})
149150
!x.re && x.im && return IM

src/deprecated.jl

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# This file contains numerous deprecations for `SymPy`
2+
#
3+
# `SymPy` took a pretty lenient approach to what it wrapped -- it if was a member
4+
# of the `sympy` object, essentially it got wrapped. (cf. `importexport.jl`)
5+
# The `SymPyCore` backend takes a much more selective approach, consequently not
6+
# adding `Julia` methods for many `sympy` functions.
7+
#
8+
# This file contains many deprecations. There are a few others utilizing `Base.depwarn`
9+
# elswhere.
10+
#
11+
# The following are to be deprecated, but didn't easily fit with `Julia`'s deprecations:
12+
#
13+
# * `True` and `False` are deprecated in favor of `Sym(true)` and `Sym(false)`. (`SymPy` didn't properly wrap `BooleanTrue` or `BooleanFalse`.
14+
#
15+
# * The python object `sympy_core` can just be `sympy.core`. Similarly `sympy_matrices` is sjust `sympy.matrices`.
16+
#
17+
# * The macro `@vars` is deprecated in favor of `@syms`; `@symfuns` is deprecated, as `@syms` can be used.
18+
#
19+
# * the `import_from` method to import all functions and wrap them from some module is deprecated.
20+
#
21+
# That should be it, but if not. Apologies.
22+
23+
Base.@deprecate conjugate(x::Sym, args...; kwargs...) conj(x, args...; kwargs...) true
24+
25+
Base.@deprecate cse(ex::SymbolicObject, args...; kwargs...) sympy.cse(ex, args...; kwargs...) true
26+
Base.@deprecate denom(ex::SymbolicObject, args...; kwargs...) sympy.denom(ex, args...; kwargs...) true
27+
Base.@deprecate flatten(ex::SymbolicObject, args...; kwargs...) sympy.flatten(ex, args...; kwargs...) true
28+
Base.@deprecate unflatten(ex::SymbolicObject, args...; kwargs...) sympy.unflatten(ex, args...; kwargs...) true
29+
Base.@deprecate interpolate(ex::SymbolicObject, args...; kwargs...) sympy.interpolate(ex, args...; kwargs...) true
30+
Base.@deprecate intervals(ex::SymbolicObject, args...; kwargs...) sympy.intervals(ex, args...; kwargs...) true
31+
Base.@deprecate isolate(ex::SymbolicObject, args...; kwargs...) sympy.isolate(ex, args...; kwargs...) true
32+
Base.@deprecate isprime(ex::SymbolicObject, args...; kwargs...) sympy.isprime(ex, args...; kwargs...) true
33+
Base.@deprecate line_integrate(ex::SymbolicObject, args...; kwargs...) sympy.line_integrate(ex, args...; kwargs...) true
34+
Base.@deprecate ln(ex::SymbolicObject, args...; kwargs...) sympy.ln(ex, args...; kwargs...) true
35+
Base.@deprecate prime(ex::SymbolicObject, args...; kwargs...) sympy.prime(ex, args...; kwargs...) true
36+
Base.@deprecate real_root(ex::SymbolicObject, args...; kwargs...) sympy.real_root(ex, args...; kwargs...) true
37+
Base.@deprecate root(ex::SymbolicObject, args...; kwargs...) sympy.root(ex, args...; kwargs...) true
38+
Base.@deprecate rootof(ex::SymbolicObject, args...; kwargs...) sympy.rootof(ex, args...; kwargs...) true
39+
Base.@deprecate rsolve(ex::SymbolicObject, args...; kwargs...) sympy.rsolve(ex, args...; kwargs...) true
40+
Base.@deprecate srepr(ex::SymbolicObject, args...; kwargs...) sympy.srepr(ex, args...; kwargs...) true
41+
Base.@deprecate multiplicity(ex::SymbolicObject, args...; kwargs...) sympy.multiplicity(ex, args...; kwargs...) true
42+
Base.@deprecate nsimplify(ex::SymbolicObject, args...; kwargs...) sympy.nsimplify(ex, args...; kwargs...) true
43+
Base.@deprecate numer(ex::SymbolicObject, args...; kwargs...) sympy.numer(ex, args...; kwargs...) true
44+
Base.@deprecate ode_order(ex::SymbolicObject, args...; kwargs...) sympy.ode_order(ex, args...; kwargs...) true
45+
Base.@deprecate pdsolve(ex::SymbolicObject, args...; kwargs...) sympy.pdsolve(ex, args...; kwargs...) true
46+
Base.@deprecate Abs(ex::SymbolicObject, args...; kwargs...) sympy.Abs(ex, args...; kwargs...) true
47+
Base.@deprecate And(ex::SymbolicObject, args...; kwargs...) sympy.And(ex, args...; kwargs...) true
48+
Base.@deprecate DiracDelta(ex::SymbolicObject, args...; kwargs...) sympy.DiracDelta(ex, args...; kwargs...) true
49+
Base.@deprecate Equality(ex::SymbolicObject, args...; kwargs...) sympy.Equality(ex, args...; kwargs...) true
50+
Base.@deprecate GreaterThan(ex::SymbolicObject, args...; kwargs...) sympy.GreaterThan(ex, args...; kwargs...) true
51+
Base.@deprecate LessThan(ex::SymbolicObject, args...; kwargs...) sympy.LessThan(ex, args...; kwargs...) true
52+
Base.@deprecate Max(ex::SymbolicObject, args...; kwargs...) sympy.Max(ex, args...; kwargs...) true
53+
Base.@deprecate Min(ex::SymbolicObject, args...; kwargs...) sympy.Min(ex, args...; kwargs...) true
54+
Base.@deprecate Not(ex::SymbolicObject, args...; kwargs...) sympy.Not(ex, args...; kwargs...) true
55+
Base.@deprecate Or(ex::SymbolicObject, args...; kwargs...) sympy.Or(ex, args...; kwargs...) true
56+
Base.@deprecate StrictGreaterThan(ex::SymbolicObject, args...; kwargs...) sympy.StrictGreaterThan(ex, args...; kwargs...) true
57+
Base.@deprecate StrictLessThan(ex::SymbolicObject, args...; kwargs...) sympy.StrictLessThan(ex, args...; kwargs...) true
58+
Base.@deprecate Unequality(ex::SymbolicObject, args...; kwargs...) sympy.Unequality(ex, args...; kwargs...) true
59+
Base.@deprecate Xor(ex::SymbolicObject, args...; kwargs...) sympy.Xor(ex, args...; kwargs...) true
60+
61+
Base.@deprecate plot_parametric_surface(exs, args...; kwargs...) sympy.plotting.plot3d_parametric_surface(exs..., args...; kwargs...) true
62+
Base.@deprecate plot_implicit(ex, args...; kwargs...) sympy.plotting.plot_implicit(ex, args...; kwargs...) true
63+
64+
65+
# mpmath @deprecate
66+
function expj(ex::SymbolicObject, args...; kwargs...)
67+
Base.depwarn("The expj function is deprecated. To use this feature, you would need to import the python library `mpmath` and then call as `mpmath.expj(...)`.", :expj)
68+
mpmath.expj(ex, args...; kwargs...)
69+
end
70+
export expj
71+
72+
function expjpi(ex::SymbolicObject, args...; kwargs...)
73+
Base.depwarn("The expjpi function is deprecated. To use this feature, you would need to import the python library `mpmath` and then call as `mpmath.expjpi(...)`.", :expjpi)
74+
mpmath.expjpi(ex, args...; kwargs...)
75+
end
76+
export expjpi
77+
78+
function fac(ex::SymbolicObject, args...; kwargs...)
79+
Base.depwarn("The fac function is deprecated. To use this feature, you would need to import the python library `mpmath` and then call as `mpmath.fac(...)`.", :fac)
80+
mpmath.fac(ex, args...; kwargs...)
81+
end
82+
export fac
83+
84+
function nint(ex::SymbolicObject, args...; kwargs...)
85+
Base.depwarn("The nint function is deprecated. To use this feature, you would need to import the python library `mpmath` and then call as `mpmath.nint(...)`.", :nint)
86+
mpmath.nint(ex, args...; kwargs...)
87+
end
88+
export nint
89+
90+
function fib(ex::SymbolicObject, args...; kwargs...)
91+
Base.depwarn("The fib function is deprecated. To use this feature, you would need to import the python library `mpmath` and then call as `mpmath.fib(...)`.", :fib)
92+
mpmath.fib(ex, args...; kwargs...)
93+
end
94+
export fib
95+
96+
function monitor(ex::SymbolicObject, args...; kwargs...)
97+
Base.depwarn("The monitor function is deprecated. To use this feature, you would need to import the python library `mpmath` and then call as `mpmath.monitor(...)`.", :monitor)
98+
mpmath.monitor(ex, args...; kwargs...)
99+
end
100+
export monitor
101+
102+
function bernfrac(ex::SymbolicObject, args...; kwargs...)
103+
Base.depwarn("The bernfrac function is deprecated. To use this feature, you would need to import the python library `mpmath` and then call as `mpmath.bernfrac(...)`.", :bernfrac)
104+
mpmath.bernfrac(ex, args...; kwargs...)
105+
end
106+
export bernfrac
107+
108+
function doctests(ex::SymbolicObject, args...; kwargs...)
109+
Base.depwarn("The doctests function is deprecated. To use this feature, you would need to import the python library `mpmath` and then call as `mpmath.doctests(...)`.", :doctests)
110+
mpmath.doctests(ex, args...; kwargs...)
111+
end
112+
export doctests
113+
114+
function ei(ex::SymbolicObject, args...; kwargs...)
115+
Base.depwarn("The ei function is deprecated. To use this feature, you would need to import the python library `mpmath` and then call as `mpmath.ei(...)`.", :ei)
116+
mpmath.ei(ex, args...; kwargs...)
117+
end
118+
export ei
119+
120+
function timing(ex::SymbolicObject, args...; kwargs...)
121+
Base.depwarn("The timing function is deprecated. To use this feature, you would need to import the python library `mpmath` and then call as `mpmath.timing(...)`.", :timing)
122+
mpmath.timing(ex, args...; kwargs...)
123+
end
124+
export timing
125+
126+
function rgamma(ex::SymbolicObject, args...; kwargs...)
127+
Base.depwarn("The rgamma function is deprecated. To use this feature, you would need to import the python library `mpmath` and then call as `mpmath.rgamma(...)`.", :rgamma)
128+
mpmath.rgamma(ex, args...; kwargs...)
129+
end
130+
export rgamma
131+
132+
function e1(ex::SymbolicObject, args...; kwargs...)
133+
Base.depwarn("The e1 function is deprecated. To use this feature, you would need to import the python library `mpmath` and then call as `mpmath.e1(...)`.", :e1)
134+
mpmath.e1(ex, args...; kwargs...)
135+
end
136+
export e1

src/generic.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ iterate(x::Sym) = (x.__pyobject__, 0)
1010
iterate(x::Sym, state) = nothing
1111

1212

13-
Base.isless(a::Sym, b::Sym) = (a != sympy.nan && b != sympy.nan) && sympy.Lt(a,b) == True
13+
Base.isless(a::Sym, b::Sym) = (a != sympy.nan && b != sympy.nan) && sympy.Lt(a,b) == Sym(true)
1414
Base.isless(a::Sym, b::Number) = isless(promote(a,b)...)
1515
Base.isless(a::Number, b::Sym) = isless(promote(a,b)...)
1616

17-
Base.isequal(a::Sym, b::Sym) = Eq(a,b) == True
18-
Base.isequal(a::Sym, b::Number) = Eq(promote(a,b)...) == True
19-
Base.isequal(a::Number, b::Sym) = Eq(promote(a,b)...) == True
17+
Base.isequal(a::Sym, b::Sym) = Eq(a,b) == Sym(true)
18+
Base.isequal(a::Sym, b::Number) = Eq(promote(a,b)...) == Sym(true)
19+
Base.isequal(a::Number, b::Sym) = Eq(promote(a,b)...) == Sym(true)
2020

2121

2222
# Floating point bits

0 commit comments

Comments
 (0)