Skip to content

Commit 9c6965e

Browse files
author
a
committed
adjust
1 parent 49b30a0 commit 9c6965e

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SymbolicUtils"
22
uuid = "d1185830-fcd6-423d-90d6-eec64667417b"
33
authors = ["Shashi Gowda"]
4-
version = "1.5.1"
4+
version = "1.6.0"
55

66
[deps]
77
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"

src/inspect.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function AbstractTrees.nodevalue(x::BasicSymbolic)
2727
end
2828

2929
function AbstractTrees.children(x::Symbolic)
30-
isexpr(x) ? children(x) : ()
30+
isexpr(x) ? arguments(x) : ()
3131
end
3232

3333
"""

src/polyform.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ function similarterm(::PolyForm, f::Union{typeof(*), typeof(+), typeof(^)},
184184
f(args...)
185185
end
186186

187-
head(x::PolyForm) = MP.nterms(x.p) == 1 ? (*) : (+)
188-
operation(x::PolyForm) = head(x)
187+
head(::PolyForm) = PolyForm
188+
operation(x::PolyForm) = MP.nterms(x.p) == 1 ? (*) : (+)
189189

190190
function arguments(x::PolyForm{T}) where {T}
191191

@@ -231,6 +231,7 @@ function arguments(x::PolyForm{T}) where {T}
231231
PolyForm{T}(t, x.pvar2sym, x.sym2term, nothing)) for t in ts]
232232
end
233233
end
234+
children(x::PolyForm) = [operation(x); arguments(x)]
234235

235236
Base.show(io::IO, x::PolyForm) = show_term(io, x)
236237

src/types.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ symtype(x::Number) = typeof(x)
102102
@inline symtype(::Symbolic{T}) where T = T
103103

104104
# We're returning a function pointer
105-
@inline function head(x::BasicSymbolic)
105+
@inline function operation(x::BasicSymbolic)
106106
@compactified x::BasicSymbolic begin
107107
Term => x.f
108108
Add => (+)
@@ -113,7 +113,7 @@ symtype(x::Number) = typeof(x)
113113
_ => error_on_type()
114114
end
115115
end
116-
@inline operation(x) = head(x)
116+
@inline head(x::BasicSymbolic) = BasicSymbolic
117117

118118
function arguments(x::BasicSymbolic)
119119
args = unsorted_arguments(x)
@@ -136,7 +136,7 @@ function arguments(x::BasicSymbolic)
136136
end
137137
return args
138138
end
139-
children(x::BasicSymbolic) = arguments(x)
139+
children(x::BasicSymbolic) = [operation(x); arguments(x)]
140140
function unsorted_arguments(x::BasicSymbolic)
141141
@compactified x::BasicSymbolic begin
142142
Term => return x.arguments

src/utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ macro matchable(expr)
222222
SymbolicUtils.iscall(::$name) = true
223223
SymbolicUtils.head(::$name) = $name
224224
SymbolicUtils.operation(::$name) = $name
225-
SymbolicUtils.children(x::$name) = getfield.((x,), ($(QuoteNode.(fields)...),))
226-
SymbolicUtils.arguments(x::$name) = SymbolicUtils.children(x)
225+
SymbolicUtils.arguments(x::$name) = getfield.((x,), ($(QuoteNode.(fields)...),))
226+
SymbolicUtils.children(x::$name) = [SymbolicUtils.operation(x); SymbolicUtils.children(x)]
227227
Base.length(x::$name) = $(length(fields) + 1)
228228
SymbolicUtils.similarterm(x::$name, f, args, type; kw...) = f(args...)
229229
end |> esc

0 commit comments

Comments
 (0)