Skip to content

Commit

Permalink
fix depwarns in utils
Browse files Browse the repository at this point in the history
  • Loading branch information
shashi committed May 30, 2024
1 parent b844e62 commit d774562
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,7 @@ with `head` as the head and `args` as the arguments, `type` as the symtype
and `metadata` as the metadata. By default this will execute `head(args...)`.
`x` parameter can also be a `Type`. The `exprhead` keyword argument is useful
when manipulating `Expr`s.
`similarterm` is deprecated see help for `maketerm` instead.
"""
function similarterm end
2 changes: 1 addition & 1 deletion src/rule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ function (acr::ACRule)(term)
if result !== nothing
# Assumption: inds are unique
length(args) == length(inds) && return result
return similarterm(term, f, [result, (args[i] for i in eachindex(args) if i inds)...], symtype(term))
return maketerm(typeof(term), f, [result, (args[i] for i in eachindex(args) if i inds)...], symtype(term), metadata(term))
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function fold(t)
# evaluate it
return operation(t)(tt...)
else
return similarterm(t, operation(t), tt)
return maketerm(typeof(t), operation(t), tt, symtype(t), metadata(t))
end
else
return t
Expand Down Expand Up @@ -147,19 +147,19 @@ function flatten_term(⋆, x)
push!(flattened_args, t)
end
end
similarterm(x, , flattened_args)
maketerm(typeof(x), , flattened_args, symtype(x), metadata(x))
end

function sort_args(f, t)
args = arguments(t)
if length(args) < 2
return similarterm(t, f, args)
return maketerm(typeof(t), f, args, symtype(t), metadata(t))
elseif length(args) == 2
x, y = args
return similarterm(t, f, x <ₑ y ? [x,y] : [y,x])
return maketerm(typeof(t), f, x <ₑ y ? [x,y] : [y,x], symtype(t), metadata(t))
end
args = args isa Tuple ? [args...] : args
similarterm(t, f, sort(args, lt=<ₑ))
maketerm(typeof(t), f, sort(args, lt=<), symtype(t), metadata(t))
end

# Linked List interface
Expand Down Expand Up @@ -225,7 +225,7 @@ macro matchable(expr)
SymbolicUtils.arguments(x::$name) = getfield.((x,), ($(QuoteNode.(fields)...),))
SymbolicUtils.children(x::$name) = [SymbolicUtils.operation(x); SymbolicUtils.children(x)]
Base.length(x::$name) = $(length(fields) + 1)
SymbolicUtils.similarterm(x::$name, f, args, type; kw...) = f(args...)
SymbolicUtils.maketerm(x::$name, f, args, type, metadata) = f(args...)
end |> esc
end

Expand Down

0 comments on commit d774562

Please sign in to comment.