Skip to content

Commit fc40a8a

Browse files
committed
SymbolicUtils, not TermInterface; use .py
1 parent 00b7982 commit fc40a8a

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
1515
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
1616

1717
[weakdeps]
18-
TermInterface = "8ea1fca8-c5ef-4a55-8b96-4e9afe9c9a3c"
1918
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
19+
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
2020

2121
[extensions]
22-
SymPyPythonCallTermInterfaceExt = "TermInterface"
2322
SymPyPythonCallSymbolicsExt = "Symbolics"
23+
SymPyPythonCallSymbolicUtilsExt = "SymbolicUtils"
2424

2525
[compat]
2626
julia = "1.6.1"
@@ -34,8 +34,8 @@ SpecialFunctions = "0.8, 0.9, 0.10, 1.0, 2"
3434

3535
[extras]
3636
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
37-
TermInterface = "8ea1fca8-c5ef-4a55-8b96-4e9afe9c9a3c"
3837
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
38+
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
3939

4040
[targets]
4141
test = ["Test"]

ext/SymPyPythonCallTermInterfaceExt.jl renamed to ext/SymPyPythonCallSymbolicUtilsExt.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
module SymPyPythonCallTermInterfaceExt
1+
module SymPyPythonCallSymbolicUtilsExt
22

33
import SymPyPythonCall
4-
import TermInterface
4+
import SymbolicUtils
55

66
#==
77
Check if x represents an expression tree. If returns true, it will be assumed that operation(::T) and arguments(::T) methods are defined. Definining these three should allow use of SymbolicUtils.simplify on custom types. Optionally symtype(x) can be defined to return the expected type of the symbolic expression.
88
==#
9-
function TermInterface.istree(x::SymPyPythonCall.SymbolicObject)
9+
function SymbolicUtils.istree(x::SymPyPythonCall.SymbolicObject)
1010
!(convert(Bool, x.is_Atom))
1111
end
1212

1313
#==
1414
f x is a term as defined by istree(x), exprhead(x) must return a symbol, corresponding to the head of the Expr most similar to the term x. If x represents a function call, for example, the exprhead is :call. If x represents an indexing operation, such as arr[i], then exprhead is :ref. Note that exprhead is different from operation and both functions should be defined correctly in order to let other packages provide code generation and pattern matching features.
15-
==#
1615
function TermInterface.exprhead(x::SymPyPythonCall.SymbolicObject)
1716
:call # this is not right
1817
end
18+
==#
1919

2020
#==
2121
Returns the head (a function object) performed by an expression tree. Called only if istree(::T) is true. Part of the API required for simplify to work. Other required methods are arguments and istree
2222
==#
23-
function TermInterface.operation(x::SymPyPythonCall.SymbolicObject)
24-
@assert TermInterface.istree(x)
23+
function SymbolicUtils.operation(x::SymPyPythonCall.SymbolicObject)
24+
@assert SymbolicUtils.istree(x)
2525
nm = Symbol(SymPyPythonCall.Introspection.funcname(x))
2626

2727
λ = get(SymPyPythonCall.Introspection.funcname2function, nm, nothing)
@@ -36,15 +36,15 @@ end
3636
#==
3737
Returns the arguments (a Vector) for an expression tree. Called only if istree(x) is true. Part of the API required for simplify to work. Other required methods are operation and istree
3838
==#
39-
function TermInterface.arguments(x::SymPyPythonCall.SymbolicObject)
39+
function SymbolicUtils.arguments(x::SymPyPythonCall.SymbolicObject)
4040
collect(SymPyPythonCall.Introspection.args(x))
4141
end
4242

4343
#==
4444
Construct a new term with the operation f and arguments args, the term should be similar to t in type. if t is a SymbolicUtils.Term object a new Term is created with the same symtype as t. If not, the result is computed as f(args...). Defining this method for your term type will reduce any performance loss in performing f(args...) (esp. the splatting, and redundant type computation). T is the symtype of the output term. You can use SymbolicUtils.promote_symtype to infer this type. The exprhead keyword argument is useful when creating Exprs.
4545
==#
46-
function TermInterface.similarterm(t::SymPyPythonCall.SymbolicObject, f, args, symtype=nothing;
47-
metadata=nothing, exprhead=TermInterface.exprhead(t))
46+
function SymbolicUtils.similarterm(t::SymPyPythonCall.SymbolicObject, f, args, symtype=nothing;
47+
metadata=nothing, exprhead=:call)
4848
f(args...) # default
4949
end
5050

ext/SymPyPythonCallSymbolicsExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ module SymPyPythonCallSymbolicsExt
33
# from https://github.com/JuliaSymbolics/Symbolics.jl/pull/957/
44
# by @jClugstor
55
using SymPyPythonCall
6+
const sp = SymPyPythonCall.sympy.py
67
const PythonCall = SymPyPythonCall.PythonCall
78
import SymPyPythonCall.PythonCall: Py, pyisinstance, pyconvert
89

910
import Symbolics
1011
import Symbolics: @variables
11-
const sp = SymPyPythonCall.sympy
1212

1313
# rule functions
1414
function pyconvert_rule_sympy_symbol(::Type{Symbolics.Num}, x::Py)

0 commit comments

Comments
 (0)