Skip to content

Commit

Permalink
Merge pull request #1158 from TorkelE/rewrite_deprecation_warnings
Browse files Browse the repository at this point in the history
Rewrite deprecation warnings
  • Loading branch information
ChrisRackauckas authored Jun 5, 2024
2 parents daedea8 + d118fcc commit 473bed6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/rewrite-helpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ end
replacenode(expr::Num, rules...; fixpoint = false) = _replacenode(unwrap(expr), rules...; fixpoint)
replacenode(expr::Symbolic, rules...; fixpoint = false) = _replacenode(unwrap(expr), rules...; fixpoint)
replacenode(expr::Symbolic, r::Pair, rules::Pair...; fixpoint = false) = _replacenode(expr, r, rules...; fixpoint)
replacenode(expr::Number, rules...; fixpoint = false) = expr
replacenode(expr::Number, r::Pair, rules::Pair...; fixpoint = false) = expr

function _replacenode(expr::Symbolic, rules...; fixpoint = false)
rs = map(r -> r isa Pair ? (x -> isequal(x, r[1]) ? r[2] : nothing) : r, rules)
Expand All @@ -32,6 +30,13 @@ function _replacenode(expr::Symbolic, rules...; fixpoint = false)
end
end

Base.@deprecate replace(expr::Num, r::Pair, rules::Pair...; fixpoint = false) replacenode(expr, r, rules...)
Base.@deprecate replace(expr::Num, rules...; fixpoint = false) replacenode(expr, rules...)
Base.@deprecate replace(expr::Symbolic, rules...; fixpoint = false) replacenode(expr, rules...)
Base.@deprecate replace(expr::Symbolic, r::Pair, rules::Pair...; fixpoint = false) replacenode(expr, r, rules...)
Base.@deprecate replace(expr::Number, rules...; fixpoint = false) replacenode(expr, rules...)
Base.@deprecate replace(expr::Number, r::Pair, rules::Pair...; fixpoint = false) replacenode(expr, r, rules...)

"""
hasnode(c, x)
Returns true if any part of `x` fufills the condition given in c. c can be a function or an expression.
Expand Down Expand Up @@ -74,6 +79,10 @@ function _hasnode(r, y)
end
end

Base.@deprecate occursin(r::Function, y::Union{Num, Symbolic}) hasnode(r::Function, y::Union{Num, Symbolic})
Base.@deprecate occursin(r::Num, y::Union{Num, Symbolic}) hasnode(r::Num, y::Union{Num, Symbolic})
Base.@deprecate occursin(r::Symbolic, y::Union{Num, Symbolic}) hasnode(r::Symbolic, y::Union{Num, Symbolic})

"""
filterchildren(c, x)
Returns all parts of `x` that fufills the condition given in c. c can be a function or an expression.
Expand Down

0 comments on commit 473bed6

Please sign in to comment.