From d7610a585771523287daf345ad0e71722801dc61 Mon Sep 17 00:00:00 2001 From: john verzani Date: Sat, 21 Oct 2023 17:50:19 -0400 Subject: [PATCH] Deprecate functions not supported in SymPyCore (#533) * Deprecate functions not supported in SymPyCore * comment on deprecations --- Project.toml | 2 +- README.md | 10 ++++ src/SymPy.jl | 4 +- src/constructors.jl | 3 +- src/deprecated.jl | 136 ++++++++++++++++++++++++++++++++++++++++++++ src/generic.jl | 8 +-- src/importexport.jl | 97 +++++++++++++++---------------- src/lambdify.jl | 2 +- src/permutations.jl | 7 ++- src/plot_recipes.jl | 58 ++++++++++--------- src/sets.jl | 5 +- src/symfunction.jl | 2 +- src/types.jl | 22 ++++++- src/utils.jl | 3 +- 14 files changed, 271 insertions(+), 88 deletions(-) create mode 100644 src/deprecated.jl diff --git a/Project.toml b/Project.toml index c2ce5416..2da4f23c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "SymPy" uuid = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6" -version = "1.1.14" +version = "1.2.0" [deps] CommonEq = "3709ef60-1bee-4518-9f2f-acd86f176c50" diff --git a/README.md b/README.md index a2356e8b..21be0f0d 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,16 @@ [![](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliapy.github.io/SymPy.jl/dev/) +> **Note** +> `SymPy` is on the move... Well, actually, the `SymPy.jl` package is planned to utilize +> 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). +> +> The plan is: +> +> * `v"1.2.0"` will include most all deprecations. See `src/deprecated.jl` for details +> +> * `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. + # SymPy Package to bring Python's `SymPy` functionality into `Julia` via `PyCall` diff --git a/src/SymPy.jl b/src/SymPy.jl index bc0027e3..057e2631 100644 --- a/src/SymPy.jl +++ b/src/SymPy.jl @@ -81,6 +81,7 @@ include("permutations.jl") include("plot_recipes.jl") include("latexify_recipe.jl") +include("deprecated.jl") ################################################## pynull() = PyCall.PyNULL() @@ -121,6 +122,7 @@ global False = Sym(pynull()) + # Can not actually initiate many things until `sympy` is defined, so not until runtime function __init__() @@ -144,7 +146,7 @@ function __init__() # can't load end - # pull in alibrary + # pull in a library copy!(combinatorics, PyCall.pyimport_conda("sympy.combinatorics", "sympy")) diff --git a/src/constructors.jl b/src/constructors.jl index 1b084755..da75f7ba 100644 --- a/src/constructors.jl +++ b/src/constructors.jl @@ -30,7 +30,7 @@ Examples: @vars a b real=true ``` !!! Note: - The `@syms` macro is recommended as it has a more flexible syntax + The `@vars` macro is deprecated and will be removed. Use `@syms`. """ macro vars(x...) q = Expr(:block) @@ -144,6 +144,7 @@ end ## avoid PyObject conversion as possible Sym(x::T) where {T <: Number} = sympify(x) +Sym(x::Bool) = Sym(PyObject(x)) Sym(x::Rational{T}) where {T} = Sym(numerator(x))/Sym(denominator(x)) function Sym(x::Complex{Bool}) !x.re && x.im && return IM diff --git a/src/deprecated.jl b/src/deprecated.jl new file mode 100644 index 00000000..eae25771 --- /dev/null +++ b/src/deprecated.jl @@ -0,0 +1,136 @@ +# This file contains numerous deprecations for `SymPy` +# +# `SymPy` took a pretty lenient approach to what it wrapped -- it if was a member +# of the `sympy` object, essentially it got wrapped. (cf. `importexport.jl`) +# The `SymPyCore` backend takes a much more selective approach, consequently not +# adding `Julia` methods for many `sympy` functions. +# +# This file contains many deprecations. There are a few others utilizing `Base.depwarn` +# elswhere. +# +# The following are to be deprecated, but didn't easily fit with `Julia`'s deprecations: +# +# * `True` and `False` are deprecated in favor of `Sym(true)` and `Sym(false)`. (`SymPy` didn't properly wrap `BooleanTrue` or `BooleanFalse`. +# +# * The python object `sympy_core` can just be `sympy.core`. Similarly `sympy_matrices` is sjust `sympy.matrices`. +# +# * The macro `@vars` is deprecated in favor of `@syms`; `@symfuns` is deprecated, as `@syms` can be used. +# +# * the `import_from` method to import all functions and wrap them from some module is deprecated. +# +# That should be it, but if not. Apologies. + +Base.@deprecate conjugate(x::Sym, args...; kwargs...) conj(x, args...; kwargs...) true + +Base.@deprecate cse(ex::SymbolicObject, args...; kwargs...) sympy.cse(ex, args...; kwargs...) true +Base.@deprecate denom(ex::SymbolicObject, args...; kwargs...) sympy.denom(ex, args...; kwargs...) true +Base.@deprecate flatten(ex::SymbolicObject, args...; kwargs...) sympy.flatten(ex, args...; kwargs...) true +Base.@deprecate unflatten(ex::SymbolicObject, args...; kwargs...) sympy.unflatten(ex, args...; kwargs...) true +Base.@deprecate interpolate(ex::SymbolicObject, args...; kwargs...) sympy.interpolate(ex, args...; kwargs...) true +Base.@deprecate intervals(ex::SymbolicObject, args...; kwargs...) sympy.intervals(ex, args...; kwargs...) true +Base.@deprecate isolate(ex::SymbolicObject, args...; kwargs...) sympy.isolate(ex, args...; kwargs...) true +Base.@deprecate isprime(ex::SymbolicObject, args...; kwargs...) sympy.isprime(ex, args...; kwargs...) true +Base.@deprecate line_integrate(ex::SymbolicObject, args...; kwargs...) sympy.line_integrate(ex, args...; kwargs...) true +Base.@deprecate ln(ex::SymbolicObject, args...; kwargs...) sympy.ln(ex, args...; kwargs...) true +Base.@deprecate prime(ex::SymbolicObject, args...; kwargs...) sympy.prime(ex, args...; kwargs...) true +Base.@deprecate real_root(ex::SymbolicObject, args...; kwargs...) sympy.real_root(ex, args...; kwargs...) true +Base.@deprecate root(ex::SymbolicObject, args...; kwargs...) sympy.root(ex, args...; kwargs...) true +Base.@deprecate rootof(ex::SymbolicObject, args...; kwargs...) sympy.rootof(ex, args...; kwargs...) true +Base.@deprecate rsolve(ex::SymbolicObject, args...; kwargs...) sympy.rsolve(ex, args...; kwargs...) true +Base.@deprecate srepr(ex::SymbolicObject, args...; kwargs...) sympy.srepr(ex, args...; kwargs...) true +Base.@deprecate multiplicity(ex::SymbolicObject, args...; kwargs...) sympy.multiplicity(ex, args...; kwargs...) true +Base.@deprecate nsimplify(ex::SymbolicObject, args...; kwargs...) sympy.nsimplify(ex, args...; kwargs...) true +Base.@deprecate numer(ex::SymbolicObject, args...; kwargs...) sympy.numer(ex, args...; kwargs...) true +Base.@deprecate ode_order(ex::SymbolicObject, args...; kwargs...) sympy.ode_order(ex, args...; kwargs...) true +Base.@deprecate pdsolve(ex::SymbolicObject, args...; kwargs...) sympy.pdsolve(ex, args...; kwargs...) true +Base.@deprecate Abs(ex::SymbolicObject, args...; kwargs...) sympy.Abs(ex, args...; kwargs...) true +Base.@deprecate And(ex::SymbolicObject, args...; kwargs...) sympy.And(ex, args...; kwargs...) true +Base.@deprecate DiracDelta(ex::SymbolicObject, args...; kwargs...) sympy.DiracDelta(ex, args...; kwargs...) true +Base.@deprecate Equality(ex::SymbolicObject, args...; kwargs...) sympy.Equality(ex, args...; kwargs...) true +Base.@deprecate GreaterThan(ex::SymbolicObject, args...; kwargs...) sympy.GreaterThan(ex, args...; kwargs...) true +Base.@deprecate LessThan(ex::SymbolicObject, args...; kwargs...) sympy.LessThan(ex, args...; kwargs...) true +Base.@deprecate Max(ex::SymbolicObject, args...; kwargs...) sympy.Max(ex, args...; kwargs...) true +Base.@deprecate Min(ex::SymbolicObject, args...; kwargs...) sympy.Min(ex, args...; kwargs...) true +Base.@deprecate Not(ex::SymbolicObject, args...; kwargs...) sympy.Not(ex, args...; kwargs...) true +Base.@deprecate Or(ex::SymbolicObject, args...; kwargs...) sympy.Or(ex, args...; kwargs...) true +Base.@deprecate StrictGreaterThan(ex::SymbolicObject, args...; kwargs...) sympy.StrictGreaterThan(ex, args...; kwargs...) true +Base.@deprecate StrictLessThan(ex::SymbolicObject, args...; kwargs...) sympy.StrictLessThan(ex, args...; kwargs...) true +Base.@deprecate Unequality(ex::SymbolicObject, args...; kwargs...) sympy.Unequality(ex, args...; kwargs...) true +Base.@deprecate Xor(ex::SymbolicObject, args...; kwargs...) sympy.Xor(ex, args...; kwargs...) true + +Base.@deprecate plot_parametric_surface(exs, args...; kwargs...) sympy.plotting.plot3d_parametric_surface(exs..., args...; kwargs...) true +Base.@deprecate plot_implicit(ex, args...; kwargs...) sympy.plotting.plot_implicit(ex, args...; kwargs...) true + + +# mpmath @deprecate +function expj(ex::SymbolicObject, args...; kwargs...) + 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) + mpmath.expj(ex, args...; kwargs...) +end +export expj + +function expjpi(ex::SymbolicObject, args...; kwargs...) + 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) + mpmath.expjpi(ex, args...; kwargs...) +end +export expjpi + +function fac(ex::SymbolicObject, args...; kwargs...) + 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) + mpmath.fac(ex, args...; kwargs...) +end +export fac + +function nint(ex::SymbolicObject, args...; kwargs...) + 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) + mpmath.nint(ex, args...; kwargs...) +end +export nint + +function fib(ex::SymbolicObject, args...; kwargs...) + 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) + mpmath.fib(ex, args...; kwargs...) +end +export fib + +function monitor(ex::SymbolicObject, args...; kwargs...) + 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) + mpmath.monitor(ex, args...; kwargs...) +end +export monitor + +function bernfrac(ex::SymbolicObject, args...; kwargs...) + 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) + mpmath.bernfrac(ex, args...; kwargs...) +end +export bernfrac + +function doctests(ex::SymbolicObject, args...; kwargs...) + 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) + mpmath.doctests(ex, args...; kwargs...) +end +export doctests + +function ei(ex::SymbolicObject, args...; kwargs...) + 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) + mpmath.ei(ex, args...; kwargs...) +end +export ei + +function timing(ex::SymbolicObject, args...; kwargs...) + 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) + mpmath.timing(ex, args...; kwargs...) +end +export timing + +function rgamma(ex::SymbolicObject, args...; kwargs...) + 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) + mpmath.rgamma(ex, args...; kwargs...) +end +export rgamma + +function e1(ex::SymbolicObject, args...; kwargs...) + 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) + mpmath.e1(ex, args...; kwargs...) +end +export e1 diff --git a/src/generic.jl b/src/generic.jl index b27e56e7..3ae184b8 100644 --- a/src/generic.jl +++ b/src/generic.jl @@ -10,13 +10,13 @@ iterate(x::Sym) = (x.__pyobject__, 0) iterate(x::Sym, state) = nothing -Base.isless(a::Sym, b::Sym) = (a != sympy.nan && b != sympy.nan) && sympy.Lt(a,b) == True +Base.isless(a::Sym, b::Sym) = (a != sympy.nan && b != sympy.nan) && sympy.Lt(a,b) == Sym(true) Base.isless(a::Sym, b::Number) = isless(promote(a,b)...) Base.isless(a::Number, b::Sym) = isless(promote(a,b)...) -Base.isequal(a::Sym, b::Sym) = Eq(a,b) == True -Base.isequal(a::Sym, b::Number) = Eq(promote(a,b)...) == True -Base.isequal(a::Number, b::Sym) = Eq(promote(a,b)...) == True +Base.isequal(a::Sym, b::Sym) = Eq(a,b) == Sym(true) +Base.isequal(a::Sym, b::Number) = Eq(promote(a,b)...) == Sym(true) +Base.isequal(a::Number, b::Sym) = Eq(promote(a,b)...) == Sym(true) # Floating point bits diff --git a/src/importexport.jl b/src/importexport.jl index 7bb7b1bc..e00a739d 100644 --- a/src/importexport.jl +++ b/src/importexport.jl @@ -1,19 +1,20 @@ ### These are generated by a) uncommenting import_sympy() in __init__ b) uncomment println parts in import_from -expj(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :expj)(ex, Sym.(args)...; kwargs...); export expj -fac(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :fac)(ex, Sym.(args)...; kwargs...); export fac -nint(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :nint)(ex, Sym.(args)...; kwargs...); export nint +#XX expj(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :expj)(ex, Sym.(args)...; kwargs...); export expj +#fac(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :fac)(ex, Sym.(args)...; kwargs...); export fac +#nint(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :nint)(ex, Sym.(args)...; kwargs...); export nint Base.ceil(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :ceil)(ex, Sym.(args)...; kwargs...) -fib(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :fib)(ex, Sym.(args)...; kwargs...); export fib -monitor(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :monitor)(ex, Sym.(args)...; kwargs...); export monitor +#fib(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :fib)(ex, Sym.(args)...; kwargs...); export fib +#monitor(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :monitor)(ex, Sym.(args)...; kwargs...); export monitor Base.cospi(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :cospi)(ex, Sym.(args)...; kwargs...) -bernfrac(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :bernfrac)(ex, Sym.(args)...; kwargs...); export bernfrac -doctests(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :doctests)(ex, Sym.(args)...; kwargs...); export doctests -ei(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :ei)(ex, Sym.(args)...; kwargs...); export ei +#bernfrac(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :bernfrac)(ex, Sym.(args)...; kwargs...); export bernfrac +#doctests(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :doctests)(ex, Sym.(args)...; kwargs...); export doctests +#ei(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :ei)(ex, Sym.(args)...; kwargs...); export ei Base.sinpi(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :sinpi)(ex, Sym.(args)...; kwargs...) -timing(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :timing)(ex, Sym.(args)...; kwargs...); export timing -rgamma(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :rgamma)(ex, Sym.(args)...; kwargs...); export rgamma -expjpi(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :expjpi)(ex, Sym.(args)...; kwargs...); export expjpi -e1(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :e1)(ex, Sym.(args)...; kwargs...); export e1 +#timing(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :timing)(ex, Sym.(args)...; kwargs...); export timing +#rgamma(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :rgamma)(ex, Sym.(args)...; kwargs...); export rgamma +#expjpi(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :expjpi)(ex, Sym.(args)...; kwargs...); export expjpi +#e1(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :e1)(ex, Sym.(args)...; kwargs...); export e1 + SpecialFunctions.ellipk(ex::SymbolicObject, args...; kwargs...)=getproperty(mpmath, :ellipk)(ex, Sym.(args)...; kwargs...); SpecialFunctions.digamma(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :digamma)(ex, Sym.(args)...; kwargs...) #Base.rem(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :rem)(ex, Sym.(args)...; kwargs...) @@ -88,64 +89,64 @@ Base.sin(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :sin)(ex, Sy simplify(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :simplify)(ex, Sym.(args)...; kwargs...); export simplify summation(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :summation)(ex, Sym.(args)...; kwargs...); export summation solve(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :solve)(ex, Sym.(args)...; kwargs...); export solve -Max(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :Max)(ex, Sym.(args)...; kwargs...); export Max -unflatten(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :unflatten)(ex, Sym.(args)...; kwargs...); export unflatten -denom(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :denom)(ex, Sym.(args)...; kwargs...); export denom +#Max(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :Max)(ex, Sym.(args)...; kwargs...); export Max +#XXXunflatten(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :unflatten)(ex, Sym.(args)...; kwargs...); export unflatten +#denom(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :denom)(ex, Sym.(args)...; kwargs...); export denom nonlinsolve(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :nonlinsolve)(ex, Sym.(args)...; kwargs...); export nonlinsolve cancel(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :cancel)(ex, Sym.(args)...; kwargs...); export cancel solveset(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :solveset)(ex, Sym.(args)...; kwargs...); export solveset -DiracDelta(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :DiracDelta)(ex, Sym.(args)...; kwargs...); export DiracDelta -Or(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :Or)(ex, Sym.(args)...; kwargs...); export Or +#DiracDelta(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :DiracDelta)(ex, Sym.(args)...; kwargs...); export DiracDelta +#Or(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :Or)(ex, Sym.(args)...; kwargs...); export Or conjugate(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :conjugate)(ex, Sym.(args)...; kwargs...); export conjugate -flatten(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :flatten)(ex, Sym.(args)...; kwargs...); export flatten -Not(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :Not)(ex, Sym.(args)...; kwargs...); export Not +#XXX flatten(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :flatten)(ex, Sym.(args)...; kwargs...); export flatten +#Not(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :Not)(ex, Sym.(args)...; kwargs...); export Not integrate(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :integrate)(ex, Sym.(args)...; kwargs...); export integrate roots(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :roots)(ex, Sym.(args)...; kwargs...); export roots factor(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :factor)(ex, Sym.(args)...; kwargs...); export factor -pdsolve(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :pdsolve)(ex, Sym.(args)...; kwargs...); export pdsolve -Abs(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :Abs)(ex, Sym.(args)...; kwargs...); export Abs +#pdsolve(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :pdsolve)(ex, Sym.(args)...; kwargs...); export pdsolve +#Abs(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :Abs)(ex, Sym.(args)...; kwargs...); export Abs Heaviside(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :Heaviside)(ex, Sym.(args)...; kwargs...); export Heaviside -nsimplify(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :nsimplify)(ex, Sym.(args)...; kwargs...); export nsimplify -isprime(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :isprime)(ex, Sym.(args)...; kwargs...); export isprime +#nsimplify(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :nsimplify)(ex, Sym.(args)...; kwargs...); export nsimplify +#isprime(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :isprime)(ex, Sym.(args)...; kwargs...); export isprime apart(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :apart)(ex, Sym.(args)...; kwargs...); export apart -Min(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :Min)(ex, Sym.(args)...; kwargs...); export Min -intervals(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :intervals)(ex, Sym.(args)...; kwargs...); export intervals -intersection(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :intersection)(ex, Sym.(args)...; kwargs...); export intersection -line_integrate(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :line_integrate)(ex, Sym.(args)...; kwargs...); export line_integrate +#Min(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :Min)(ex, Sym.(args)...; kwargs...); export Min +#intervals(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :intervals)(ex, Sym.(args)...; kwargs...); export intervals +#intersection(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :intersection)(ex, Sym.(args)...; kwargs...); export intersection +#line_integrate(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :line_integrate)(ex, Sym.(args)...; kwargs...); export line_integrate real_roots(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :real_roots)(ex, Sym.(args)...; kwargs...); export real_roots -isolate(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :isolate)(ex, Sym.(args)...; kwargs...); export isolate +#isolate(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :isolate)(ex, Sym.(args)...; kwargs...); export isolate linsolve(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :linsolve)(ex, Sym.(args)...; kwargs...); export linsolve -Xor(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :Xor)(ex, Sym.(args)...; kwargs...); export Xor -real_root(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :real_root)(ex, Sym.(args)...; kwargs...); export real_root +#Xor(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :Xor)(ex, Sym.(args)...; kwargs...); export Xor +#real_root(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :real_root)(ex, Sym.(args)...; kwargs...); export real_root nsolve(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :nsolve)(ex, Sym.(args)...; kwargs...); export nsolve -ln(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :ln)(ex, Sym.(args)...; kwargs...); export ln -rsolve(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :rsolve)(ex, Sym.(args)...; kwargs...); export rsolve +#ln(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :ln)(ex, Sym.(args)...; kwargs...); export ln +#rsolve(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :rsolve)(ex, Sym.(args)...; kwargs...); export rsolve degree(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :degree)(ex, Sym.(args)...; kwargs...); export degree -prime(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :prime)(ex, Sym.(args)...; kwargs...); export prime +#prime(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :prime)(ex, Sym.(args)...; kwargs...); export prime limit(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :limit)(ex, Sym.(args)...; kwargs...); export limit -And(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :And)(ex, Sym.(args)...; kwargs...); export And -root(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :root)(ex, Sym.(args)...; kwargs...); export root -rootof(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :rootof)(ex, Sym.(args)...; kwargs...); export rootof -ode_order(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :ode_order)(ex, Sym.(args)...; kwargs...); export ode_order -multiplicity(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :multiplicity)(ex, Sym.(args)...; kwargs...); export multiplicity +#And(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :And)(ex, Sym.(args)...; kwargs...); export And +#root(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :root)(ex, Sym.(args)...; kwargs...); export root +#rootof(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :rootof)(ex, Sym.(args)...; kwargs...); export rootof +#ode_order(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :ode_order)(ex, Sym.(args)...; kwargs...); export ode_order +#multiplicity(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :multiplicity)(ex, Sym.(args)...; kwargs...); export multiplicity series(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :series)(ex, Sym.(args)...; kwargs...); export series expand(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :expand)(ex, Sym.(args)...; kwargs...); export expand hessian(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :hessian)(ex, Sym.(args)...; kwargs...); export hessian -srepr(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :srepr)(ex, Sym.(args)...; kwargs...); export srepr +#srepr(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :srepr)(ex, Sym.(args)...; kwargs...); export srepr nroots(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :nroots)(ex, Sym.(args)...; kwargs...); export nroots -interpolate(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :interpolate)(ex, Sym.(args)...; kwargs...); export interpolate -numer(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :numer)(ex, Sym.(args)...; kwargs...); export numer -cse(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :cse)(ex, Sym.(args)...; kwargs...); export cse +#interpolate(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :interpolate)(ex, Sym.(args)...; kwargs...); export interpolate +#numer(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :numer)(ex, Sym.(args)...; kwargs...); export numer +#XXX cse(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :cse)(ex, Sym.(args)...; kwargs...); export cse together(ex::SymbolicObject, args...; kwargs...)=getproperty(sympy, :together)(ex, Sym.(args)...; kwargs...); export together -Equality(ex::Number, args...; kwargs...)=getproperty(sympy, :Equality)(ex, Sym.(args)...; kwargs...); export Equality +#Equality(ex::Number, args...; kwargs...)=getproperty(sympy, :Equality)(ex, Sym.(args)...; kwargs...); export Equality Ne(ex::Number, args...; kwargs...)=getproperty(sympy, :Ne)(ex, Sym.(args)...; kwargs...); export Ne -LessThan(ex::Number, args...; kwargs...)=getproperty(sympy, :LessThan)(ex, Sym.(args)...; kwargs...); export LessThan +#LessThan(ex::Number, args...; kwargs...)=getproperty(sympy, :LessThan)(ex, Sym.(args)...; kwargs...); export LessThan Gt(ex::Number, args...; kwargs...)=getproperty(sympy, :Gt)(ex, Sym.(args)...; kwargs...); export Gt Eq(ex::Number, args...; kwargs...)=getproperty(sympy, :Eq)(ex, Sym.(args)...; kwargs...); export Eq -GreaterThan(ex::Number, args...; kwargs...)=getproperty(sympy, :GreaterThan)(ex, Sym.(args)...; kwargs...); export GreaterThan +#GreaterThan(ex::Number, args...; kwargs...)=getproperty(sympy, :GreaterThan)(ex, Sym.(args)...; kwargs...); export GreaterThan Le(ex::Number, args...; kwargs...)=getproperty(sympy, :Le)(ex, Sym.(args)...; kwargs...); export Le Lt(ex::Number, args...; kwargs...)=getproperty(sympy, :Lt)(ex, Sym.(args)...; kwargs...); export Lt -Unequality(ex::Number, args...; kwargs...)=getproperty(sympy, :Unequality)(ex, Sym.(args)...; kwargs...); export Unequality +#Unequality(ex::Number, args...; kwargs...)=getproperty(sympy, :Unequality)(ex, Sym.(args)...; kwargs...); export Unequality Ge(ex::Number, args...; kwargs...)=getproperty(sympy, :Ge)(ex, Sym.(args)...; kwargs...); export Ge -StrictLessThan(ex::Number, args...; kwargs...)=getproperty(sympy, :StrictLessThan)(ex, Sym.(args)...; kwargs...); export StrictLessThan -StrictGreaterThan(ex::Number, args...; kwargs...)=getproperty(sympy, :StrictGreaterThan)(ex, Sym.(args)...; kwargs...); export StrictGreaterThan +#StrictLessThan(ex::Number, args...; kwargs...)=getproperty(sympy, :StrictLessThan)(ex, Sym.(args)...; kwargs...); export StrictLessThan +#StrictGreaterThan(ex::Number, args...; kwargs...)=getproperty(sympy, :StrictGreaterThan)(ex, Sym.(args)...; kwargs...); export StrictGreaterThan diff --git a/src/lambdify.jl b/src/lambdify.jl index 276a00b2..1110d78e 100644 --- a/src/lambdify.jl +++ b/src/lambdify.jl @@ -248,7 +248,7 @@ function lambdify(ex::Sym, vars=free_symbols(ex); if isempty(vars) # can't call N(ex) here... v = ex.evalf() - if v.is_real == True + if v.is_real == Sym(true) val = convert(Real, v) else val = Complex(convert(Real, real(v)), convert(Real, imag(v))) diff --git a/src/permutations.jl b/src/permutations.jl index c1e3dda4..be0be89d 100644 --- a/src/permutations.jl +++ b/src/permutations.jl @@ -201,7 +201,12 @@ rank(p::SymPermutation) = p.rank ## we want perms, not tuples -transpositions(p::SymPermutation) = map(x -> Permutation([x]), object_meth(p, :transpositions)) +function transpositions(p::SymPermutation) + Base.depwarn("This function is deprecated", + "Use `map(x -> Permutation([x]), object_meth(p, :transpositions))`", + :transpositions) + map(x -> Permutation([x]), object_meth(p, :transpositions)) +end export transpositions diff --git a/src/plot_recipes.jl b/src/plot_recipes.jl index 89b9351e..259db58b 100644 --- a/src/plot_recipes.jl +++ b/src/plot_recipes.jl @@ -181,6 +181,10 @@ plot!(rhs(out)) struct VectorField fx fy + function VectorField(fx, fy) + Base.depwarn("Vectorfield is deprecated", :VectorField) + new(fx, fy) + end end VectorField(f) = VectorField((x,y) -> 1.0, f) export VectorField @@ -216,41 +220,43 @@ end ## surface plot xvar = Tuple(Sym, Real, Real) ## -""" +# """ -Render a parametrically defined surface plot. +# Render a parametrically defined surface plot. -Example: -``` -@syms u, v -plot_parametric_surface((u*v,u-v,u+v), (u,0,1), (v,0,1)) -``` +# Example: +# ``` +# @syms u, v +# plot_parametric_surface((u*v,u-v,u+v), (u,0,1), (v,0,1)) +# ``` -This uses `PyPlot`, not `Plots` for now. -""" -function plot_parametric_surface(exs::Tuple{Sym,Sym,Sym}, - xvar=(-5.0, 5.0), - yvar=(-5.0, 5.0), - args...; - kwargs...) +# This uses `PyPlot`, not `Plots` for now. +# """ +# function plot_parametric_surface(exs::Tuple{Sym,Sym,Sym}, +# xvar=(-5.0, 5.0), +# yvar=(-5.0, 5.0), +# args...; +# kwargs...) - sympy.plotting.plot3d_parametric_surface(exs..., args...; kwargs...) +# sympy.plotting.plot3d_parametric_surface(exs..., args...; kwargs...) -end -export plot_parametric_surface +# end +# export plot_parametric_surface -""" -Plot an implicit equation +# """ +# Plot an implicit equation -``` -@syms x y -plot_implicit(Eq(x^2+ y^2,3), (x, -2, 2), (y, -2, 2)) -``` +# ``` +# @syms x y +# plot_implicit(Eq(x^2+ y^2,3), (x, -2, 2), (y, -2, 2)) +# ``` -""" -plot_implicit(ex, args...; kwargs...) = sympy.plotting.plot_implicit(ex, args...; kwargs...) -export plot_implicit +# """ +# function plot_implicit(ex, args...; kwargs...) +# sympy.plotting.plot_implicit(ex, args...; kwargs...) +# end +# export plot_implicit diff --git a/src/sets.jl b/src/sets.jl index 2afaa62d..df5f0007 100644 --- a/src/sets.jl +++ b/src/sets.jl @@ -15,7 +15,10 @@ end return elements of a set s as an array, unlike `convert(Set,s)` """ -elements(s::Sym) = collect(convert(Set, s)) +function elements(s::Sym) + Base.depwarn("`elements` is deprecated", :elements) + collect(convert(Set, s)) +end export elements # is x in set; avoid ambiguity diff --git a/src/symfunction.jl b/src/symfunction.jl index 50950ff0..3b835ece 100644 --- a/src/symfunction.jl +++ b/src/symfunction.jl @@ -168,7 +168,7 @@ end Thanks to `@alhirzel` for the contribution. !!! Note: - The `@symfuns` macro will be deprecated. The more general [`@syms`](@ref) macro should be used for constructing symbolic functions of type `SymFunction` and `symbols` can be used to construct symbolic functions in general. + The `@symfuns` macro is deprecated. The more general [`@syms`](@ref) macro should be used for constructing symbolic functions of type `SymFunction` and `symbols` can be used to construct symbolic functions in general. """ macro symfuns(x...) diff --git a/src/types.jl b/src/types.jl index e8516947..1ee2cce6 100644 --- a/src/types.jl +++ b/src/types.jl @@ -28,12 +28,21 @@ The `convert(Matrix{Sym}, M)` call is useful to covert to a Julia matrix """ mutable struct SymMatrix <: SymbolicObject __pyobject__::PyCall.PyObject + function SymMatrix(o) + Base.depwarn("The `SymMatrix` wrapper type is deprecated", :SymPermuation) + new(o) + end + end ## Permutations ## A permutation of {0, 1, 2, ..., n} -- 0-based struct SymPermutation <: SymbolicObject - __pyobject__::PyCall.PyObject + __pyobject__::PyCall.PyObject + function SymPermutation(o) + Base.depwarn("The `SymPermutation` wrapper type is deprecated", :SymPermuation) + new(o) + end end export SymPermutation Base.convert(::Type{SymPermutation}, o::PyCall.PyObject) = SymPermutation(o) @@ -41,7 +50,12 @@ Base.convert(::Type{SymPermutation}, o::PyCall.PyObject) = SymPermutation(o) ## A permutation of {0, 1, 2, ..., n} -- 0-based struct SymPermutationGroup <: SymbolicObject - __pyobject__::PyCall.PyObject + __pyobject__::PyCall.PyObject + function SymPermutationGroup(o) + Base.depwarn("The `SymPermutationGroup` wrapper type is deprecated", :SymPermuation) + new(o) + end + end export SymPermutationGroup Base.convert(::Type{SymPermutationGroup}, o::PyCall.PyObject) = SymPermutationGroup(o) @@ -49,6 +63,10 @@ Base.convert(::Type{SymPermutationGroup}, o::PyCall.PyObject) = SymPermutationGr # a Lambda function struct Lambda <: SymbolicObject __pyobject__::PyCall.PyObject + function Lambda(o) + Base.depwarn("`Lambda` is deprecated; use `sympy.Lambda(args,expression)`", :Lambda) + new(o) + end end Lambda(args, expression) = Lambda(sympy.Lambda(args, expression).__pyobject__) (λ::Lambda)(args...; kwargs...) = λ.__pyobject__(args...; kwargs...) diff --git a/src/utils.jl b/src/utils.jl index b3c4263e..e1720128 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -10,7 +10,7 @@ Examples: ```jldoctest utils julia> using SymPy -julia> i,j = sympy.symbols("i j", integer=True) +julia> i,j = sympy.symbols("i j", integer=true) (i, j) julia> x = sympy.IndexedBase("x") @@ -346,6 +346,7 @@ function import_from(sm, meths=nothing; exclude::Union{Nothing, NTuple{N,Symbol}}=nothing ) where {N} + Base.depwarn("`import_from` is deprecated", :import_from) if meths == nothing _exclude = isa(exclude, Nothing) ? base_exclude : exclude