Skip to content

Commit

Permalink
Merge pull request #1196 from JuliaSymbolics/ale/bump-su-3
Browse files Browse the repository at this point in the history
Bump SymbolicUtils to v3
  • Loading branch information
ChrisRackauckas authored Aug 11, 2024
2 parents 933757b + 6108379 commit 50d4f51
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
11 changes: 6 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Symbolics"
uuid = "0c5d862f-8b57-4792-8d23-62f2024744c7"
authors = ["Shashi Gowda <[email protected]>"]
version = "5.36.0"
version = "6.0.0"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down Expand Up @@ -36,6 +36,7 @@ Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
SymPyCore = "458b697b-88f0-4a86-b56b-78b75cfb3531"
SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5"
SymbolicLimits = "19f23fe9-fdab-4a78-91af-e7b7767979c3"
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
Expand Down Expand Up @@ -85,11 +86,11 @@ SciMLBase = "2"
Setfield = "1"
SpecialFunctions = "2"
StaticArraysCore = "1.4"
SymPy = "2"
SymPy = "2.2"
SymbolicIndexingInterface = "0.3.14"
SymbolicLimits = "0.2.0"
SymbolicUtils = "2.1"
TermInterface = "0.4"
SymbolicLimits = "0.2.2"
SymbolicUtils = "2, 3"
TermInterface = "2"
julia = "1.10"

[extras]
Expand Down
4 changes: 2 additions & 2 deletions src/Symbolics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ using Setfield
import DomainSets: Domain

using TermInterface
import TermInterface: maketerm, iscall, operation, arguments, symtype, metadata
import TermInterface: maketerm, iscall, operation, arguments, metadata

import SymbolicUtils: Term, Add, Mul, Pow, Sym, Div, BasicSymbolic,
FnType, @rule, Rewriters, substitute,
FnType, @rule, Rewriters, substitute, symtype,
promote_symtype, isadd, ismul, ispow, isterm, issym, isdiv

using SymbolicUtils.Code
Expand Down
8 changes: 4 additions & 4 deletions src/arrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ end

ConstructionBase.constructorof(s::Type{<:ArrayOp{T}}) where {T} = ArrayOp{T}

function SymbolicUtils.maketerm(::Type{<:ArrayOp}, f, args, _symtype, m)
function SymbolicUtils.maketerm(::Type{<:ArrayOp}, f, args, m)
t = f(args...)
t isa Symbolic && !isnothing(m) ?
metadata(t, m) : t
Expand Down Expand Up @@ -595,7 +595,7 @@ function replace_by_scalarizing(ex, dict)
f = operation(x)
ff = replace_by_scalarizing(f, dict)
if metadata(x) !== nothing
maketerm(typeof(x), ff, arguments(x), symtype(x), metadata(x))
maketerm(typeof(x), ff, arguments(x), metadata(x))
else
ff(arguments(x)...)
end
Expand All @@ -614,7 +614,7 @@ function prewalk_if(cond, f, t)
if iscall(t′)
if metadata(t′) !== nothing
return maketerm(typeof(t′), TermInterface.head(t′),
map(x->prewalk_if(cond, f, x), children(t′)), symtype(t′), metadata(t′))
map(x->prewalk_if(cond, f, x), children(t′)), metadata(t′))
else
TermInterface.head(t′)(map(x->prewalk_if(cond, f, x), children(t′))...)
end
Expand Down Expand Up @@ -749,7 +749,7 @@ function scalarize(arr)
elseif arr isa Num
wrap(scalarize(unwrap(arr)))
elseif iscall(arr) && symtype(arr) <: Number
t = maketerm(typeof(arr), operation(arr), map(scalarize, arguments(arr)), symtype(arr), metadata(arr))
t = maketerm(typeof(arr), operation(arr), map(scalarize, arguments(arr)), metadata(arr))
iscall(t) ? scalarize_op(operation(t), t) : t
else
arr
Expand Down
4 changes: 2 additions & 2 deletions src/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ operation(a::ComplexTerm{T}) where T = Complex{T}
arguments(a::ComplexTerm) = [a.re, a.im]
metadata(a::ComplexTerm) = metadata(a.re)

function maketerm(T::Type{<:ComplexTerm}, f, args, symtype, metadata)
function maketerm(T::Type{<:ComplexTerm}, f, args, metadata)
if f <: Complex
ComplexTerm{real(f)}(args...)
else
maketerm(typeof(first(args)), f, args, symtype, metadata)
maketerm(typeof(first(args)), f, args, metadata)
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/diff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ end

isidx(x) = x isa TermCombination

basic_mkterm(t, g, args, _, m) = metadata(Term{Any}(g, args), m)
basic_mkterm(t, g, args, m) = metadata(Term{Any}(g, args), m)

let
# we do this in a let block so that Revise works on the list of rules
Expand Down
4 changes: 2 additions & 2 deletions src/semipoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Base.:nameof(m::SemiMonomial) = Symbol(:SemiMonomial, m.p, m.coeff)
isop(x, op) = iscall(x) && operation(x) === op
isop(op) = Base.Fix2(isop, op)

simpleterm(T, f, args, sT, m) = Term{sT}(f, args)
simpleterm(T, f, args, m) = Term{SymbolicUtils._promote_symtype(f, args)}(f, args)

function mark_and_exponentiate(expr, vars)
# Step 1
Expand Down Expand Up @@ -426,7 +426,7 @@ function unwrap_sp(x)
x = unwrap(x)
iscall(x) ? maketerm(typeof(x),
TermInterface.head(x), map(unwrap_sp,
TermInterface.children(x))) : x
TermInterface.children(x)), nothing) : x
end

function cautious_sum(nls)
Expand Down
4 changes: 2 additions & 2 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function diff2term(O, O_metadata::Union{Dict, Nothing, Base.ImmutableDict}=nothi

if ds === nothing
return maketerm(typeof(O), TermInterface.head(O), map(diff2term, children(O)),
symtype(O), O_metadata isa Nothing ?
O_metadata isa Nothing ?
metadata(O) : Base.ImmutableDict(metadata(O)..., O_metadata...))
else
oldop = operation(O)
Expand All @@ -132,7 +132,7 @@ function diff2term(O, O_metadata::Union{Dict, Nothing, Base.ImmutableDict}=nothi
error("diff2term case not handled: $oldop")
end
newname = occursin(d_separator, opname) ? Symbol(opname, ds) : Symbol(opname, d_separator, ds)
return setname(maketerm(typeof(O), rename(oldop, newname), children(O), symtype(O), O_metadata isa Nothing ?
return setname(maketerm(typeof(O), rename(oldop, newname), children(O), O_metadata isa Nothing ?
metadata(O) : Base.ImmutableDict(metadata(O)..., O_metadata...)), newname)
end
end
Expand Down
2 changes: 0 additions & 2 deletions src/variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,6 @@ function fast_substitute(expr, subs; operator = Nothing)
maketerm(typeof(expr),
op,
args,
symtype(expr),
metadata(expr))
end
function fast_substitute(expr, pair::Pair; operator = Nothing)
Expand Down Expand Up @@ -519,7 +518,6 @@ function fast_substitute(expr, pair::Pair; operator = Nothing)
maketerm(typeof(expr),
op,
args,
symtype(expr),
metadata(expr))
end

Expand Down
5 changes: 3 additions & 2 deletions test/arrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ end
@variables A[1:5, 1:5] B[1:5, 1:5]

T = unwrap(3A)
@test isequal(T, Symbolics.maketerm(typeof(T), operation(T), arguments(T), symtype(T), nothing))
@test isequal(T, Symbolics.maketerm(typeof(T), operation(T), arguments(T), nothing))
T2 = unwrap(3B)
@test isequal(T2, Symbolics.maketerm(typeof(T), operation(T), [*, 3, unwrap(B)], symtype(T), nothing))
@test isequal(T2, Symbolics.maketerm(typeof(T), operation(T), [*, 3, unwrap(B)], nothing))
end

getdef(v) = getmetadata(v, Symbolics.VariableDefaultValue)
Expand Down Expand Up @@ -405,6 +405,7 @@ end
@register_array_symbolic bar(x::AbstractVector, p::AbstractMatrix) begin
size = size(x)
eltype = promote_type(eltype(x), eltype(p))
ndims = 1
end

@test isequal(substitute(bar(x, p), x => ones(3)), bar(ones(3), p))
Expand Down

0 comments on commit 50d4f51

Please sign in to comment.