Skip to content

Commit

Permalink
Deprecate functions not supported in SymPyCore (JuliaPy#533)
Browse files Browse the repository at this point in the history
* Deprecate functions not supported in SymPyCore
* comment on deprecations
  • Loading branch information
jverzani authored Oct 21, 2023
1 parent 0d6a507 commit d7610a5
Show file tree
Hide file tree
Showing 14 changed files with 271 additions and 88 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
4 changes: 3 additions & 1 deletion src/SymPy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ include("permutations.jl")
include("plot_recipes.jl")
include("latexify_recipe.jl")

include("deprecated.jl")
##################################################

pynull() = PyCall.PyNULL()
Expand Down Expand Up @@ -121,6 +122,7 @@ global False = Sym(pynull())




# Can not actually initiate many things until `sympy` is defined, so not until runtime
function __init__()

Expand All @@ -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"))


Expand Down
3 changes: 2 additions & 1 deletion src/constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
136 changes: 136 additions & 0 deletions src/deprecated.jl
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions src/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit d7610a5

Please sign in to comment.