Skip to content

Commit

Permalink
use CommonEq to avoid conflict with ImplicitEquations (#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
jverzani authored Aug 9, 2021
1 parent 9f80c8e commit 258f828
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 43 deletions.
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name = "SymPy"
uuid = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6"
version = "1.0.50"

version = "1.0.51"

[deps]
CommonEq = "3709ef60-1bee-4518-9f2f-acd86f176c50"
CommonSolve = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Expand All @@ -12,6 +12,7 @@ RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"

[compat]
CommonEq = "0.2"
CommonSolve = "0.2"
PyCall = "1.91"
RecipesBase = "0.7, 0.8, 1.0, 1.1"
Expand Down
14 changes: 6 additions & 8 deletions src/SymPy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ SymPy's [website](http://docs.sympy.org/latest/index.html).
Plotting is provided through `Plots` recipes. For details, see
the help page for [`sympy_plotting`](@ref).
The package documentation provides many examples.
The package documentation provides many examples.
"""
module SymPy
Expand All @@ -39,6 +39,8 @@ using LinearAlgebra
using Markdown
import CommonSolve
import CommonSolve: solve
import CommonEq
import CommonEq: Eq, Lt, Le, Ne, Ge, Gt, , , , ,

import Base: show
import Base: convert, promote_rule
Expand Down Expand Up @@ -80,7 +82,7 @@ pynull() = PyCall.PyNULL()
"""
sympy
Variable from `pyimport("sympy")`. Numerous methods are available through Python's dot-call syntax.
Variable from `pyimport("sympy")`. Numerous methods are available through Python's dot-call syntax.
"""
const sympy = PyCall.PyNULL()
"""
Expand Down Expand Up @@ -120,7 +122,7 @@ function __init__()
## Define sympy, mpmath, ...
copy!(sympy, PyCall.pyimport_conda("sympy", "sympy"))
copy!(sympy_core, PyCall.pyimport("sympy.core"))
copy!(sympy_matrices, PyCall.pyimport("sympy.matrices"))
copy!(sympy_matrices, PyCall.pyimport("sympy.matrices"))
copy!(PI.__pyobject__, sympy.pi)
copy!(IM.__pyobject__, sympy.I)
copy!(oo.__pyobject__, sympy.oo)
Expand Down Expand Up @@ -246,17 +248,13 @@ function import_sympy()
d1 = filter(uv -> in_base(uv) && is_function(uv), d)
import_from(sympy, setdiff(Symbol.(collect(keys(d1))), Symbol.(base_exclude)))
import_from(sympy, priviledged)
import_from(sympy, (:Ne, :Le, :Eq, :Ge, :Gt,
import_from(sympy, (:Ne, :Lt, :Le, :Eq, :Ge, :Gt,
:GreaterThan, :LessThan,
:StrictGreaterThan, :StrictLessThan,
:Equality, :Unequality
), typ=:Number)
end

## :Lt is in Base.Order
import Base.Order: Lt
Lt(x::Number, args...;kwargs...) = sympy.Lt(x, args...; kwargs...)
export(Lt)


### Add generic methods and new methods
Expand Down
1 change: 1 addition & 0 deletions src/importexport.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ Gt(ex::Number, args...; kwargs...)=getproperty(sympy, :Gt)(ex, Sym.(args)...; kw
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
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
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
Expand Down
34 changes: 1 addition & 33 deletions src/numbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -343,36 +343,4 @@ export ∨, ∧, ¬
## * `>` is `\gg<tab>`


## Instead we have:
## We use unicode for visual appeal of infix operators, but the Lt, Le, Eq, Ge, Gt are the proper way:

"This is `\\ll<tab>` mapped as an infix operator to `Lt`"
()(a::Sym, b::Sym) = Lt(a,b) # \ll<tab>
()(a::Sym, b::Number) = Lt(a,Sym(b)) # \ll<tab>
()(a::Number, b::Sym) = Lt(Sym(a),b) # \ll<tab>

## could just do this, but it would interfere with other uses outside of SymPy
## (≪)(a::Number, b::Number) = Lt(promote(a,b)...) # \ll<tab>

"This is `\\leqq<tab>` mapped as an infix operator to `Le`"
()(a::Sym, b::Sym) = Le(a,b) # \leqq<tab>
()(a::Sym, b::Number) = Le(a,Sym(b)) # \leqq<tab>
()(a::Number, b::Sym) = Le(Sym(a),b) # \leqq<tab>

"This is `\\gg<tab>` mapped as an infix operator to `Gt`"
()(a::Sym, b::Sym) = Gt(a,b)
()(a::Sym, b::Number) = Gt(a,Sym(b))
()(a::Number, b::Sym) = Gt(Sym(a),b)

"This is `\\geqq<tab>` mapped as an infix operator to `Ge`"
()(a::Sym, b::Sym) = Ge(a,b)
()(a::Sym, b::Number) = Ge(a,Sym(b))
()(a::Number, b::Sym) = Ge(Sym(a),b)

"For infix `Eq` one can use \\Equal<tab> unicode operator"
()(a::Sym, b::Sym) = Eq(a,b) # \Equal<tab>
()(a::Sym, b::Number) = Eq(a,Sym(b)) # \Equal<tab>
()(a::Number, b::Sym) = Eq(Sym(a),b) # \Equal<tab>


export ,,,,
export ,,,,, , # from CommonEq

2 comments on commit 258f828

@jverzani
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/42516

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.51 -m "<description of version>" 258f82898882f4afb20827e5408509743575803d
git push origin v1.0.51

Please sign in to comment.