Skip to content

Commit cbd12cb

Browse files
committed
Fix Sym constructions
1 parent 2eadc04 commit cbd12cb

File tree

8 files changed

+19
-20
lines changed

8 files changed

+19
-20
lines changed

src/Symbolics.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ import DomainSets: Domain
2828
using TermInterface
2929
import TermInterface: maketerm, iscall, operation, arguments, metadata
3030

31-
import SymbolicUtils: Term, Add, Mul, Pow, Sym, Div, BasicSymbolic,
32-
FnType, @rule, Rewriters, substitute, symtype,
33-
promote_symtype, isadd, ismul, ispow, isterm, issym, isdiv, _Sym
31+
import SymbolicUtils: BasicSymbolic, FnType, @rule, Rewriters, substitute, symtype,
32+
promote_symtype, isadd, ismul, ispow, isterm, issym, isdiv, _Sym
3433

3534
using SymbolicUtils.Code
3635

src/arrays.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ function get_inputs(x::ArrayOp)
10471047
end
10481048

10491049
function similar_arrayvar(ex, name)
1050-
Sym{symtype(ex)}(name) #TODO: shape?
1050+
_Sym(symtype(ex), name) #TODO: shape?
10511051
end
10521052

10531053
function reset_to_one(range)
@@ -1056,7 +1056,7 @@ function reset_to_one(range)
10561056
end
10571057

10581058
function reset_sym(i)
1059-
Sym{Int}(Symbol(nameof(i), ""))
1059+
_Sym(Int, Symbol(nameof(i), ""))
10601060
end
10611061

10621062
function inplace_expr(x::ArrayOp, outsym = :_out, intermediates = nothing)

src/build_function.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ function _build_function(target::JuliaTarget, rhss::AbstractArray, args...;
310310
oop_expr = wrap_code[1](oop_expr)
311311
end
312312

313-
out = Sym{Any}(:ˍ₋out)
313+
out = _Sym(Any, :ˍ₋out)
314314
ip_body = if iip
315315
postprocess_fbody(set_array(parallel,
316316
dargs,
@@ -553,13 +553,13 @@ _set_array(out, outputidxs, rhs, checkbounds, skipzeros, cse) = rhs
553553
function vars_to_pairs(name,vs::Union{Tuple, AbstractArray}, symsdict=Dict())
554554
vs_names = tosymbol.(vs)
555555
for (v,k) in zip(vs_names, vs)
556-
symsdict[k] = Sym{symtype(k)}(v)
556+
symsdict[k] = _Sym(symtype(k), v)
557557
end
558558
exs = [:($name[$i]) for (i, u) enumerate(vs)]
559559
vs_names,exs
560560
end
561561
function vars_to_pairs(name,vs, symsdict)
562-
symsdict[vs] = Sym{symtype(vs)}(tosymbol(vs))
562+
symsdict[vs] = _Sym(symtype(vs), tosymbol(vs))
563563
[tosymbol(vs)], [name]
564564
end
565565

src/complex.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function Base.show(io::IO, a::Complex{Num})
4848
return print(io, arguments(rr)[1])
4949
end
5050

51-
i = Sym{Real}(:im)
51+
i = _Sym(Real, :im)
5252
show(io, real(a) + i * imag(a))
5353
end
5454

src/utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function diff2term(O, O_metadata::Union{Dict, Nothing, Base.ImmutableDict}=nothi
132132
elseif oldop == getindex
133133
args = arguments(O)
134134
opname = string(tosymbol(args[1]), "[", map(tosymbol, args[2:end])..., "]")
135-
return Sym{symtype(O)}(Symbol(opname, d_separator, ds))
135+
return _Sym(symtype(O), Symbol(opname, d_separator, ds))
136136
elseif oldop isa Function
137137
return nothing
138138
else
@@ -227,7 +227,7 @@ function makesubscripts(n)
227227
map(1:n) do i
228228
repeats = ceil(Int, i / m)
229229
c = set[(i-1) % m + 1]
230-
Sym{Int}(Symbol(join([c for _ in 1:repeats], "")))
230+
_Sym(Int, Symbol(join([c for _ in 1:repeats], "")))
231231
end
232232
end
233233

src/variable.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ function construct_dep_array_vars(macroname, lhs, type, call_args, indices, val,
159159
ndim = :($length(($(indices...),)))
160160
vname = !isruntime ? Meta.quot(lhs) : lhs
161161
if call_args[1] == :..
162-
ex = :($CallWithMetadata($Sym{$FnType{Tuple, Array{$type, $ndim}}}($vname)))
162+
ex = :($CallWithMetadata($_Sym($FnType{Tuple, Array{$type, $ndim}}, $vname)))
163163
else
164-
ex = :($Sym{$FnType{Tuple, Array{$type, $ndim}}}($vname)(map($unwrap, ($(call_args...),))...))
164+
ex = :($_Sym($FnType{Tuple, Array{$type, $ndim}}, $vname)(map($unwrap, ($(call_args...),))...))
165165
end
166166
ex = :($setmetadata($ex, $ArrayShapeCtx, ($(indices...),)))
167167

@@ -281,17 +281,17 @@ function _construct_array_vars(macroname, var_name, type, call_args, val, prop,
281281

282282
need_scalarize = false
283283
expr = if call_args === nothing
284-
ex = :($Sym{Array{$type, $ndim}}($var_name))
284+
ex = :($_Sym(Array{$type, $ndim}, $var_name))
285285
:($setmetadata($ex, $ArrayShapeCtx, ($(indices...),)))
286286
elseif !isempty(call_args) && call_args[end] == :..
287287
need_scalarize = true
288-
ex = :($Sym{Array{$FnType{Tuple, $type}, $ndim}}($var_name))
288+
ex = :($_Sym(Array{$FnType{Tuple, $type}, $ndim}, $var_name))
289289
ex = :($setmetadata($ex, $ArrayShapeCtx, ($(indices...),)))
290290
:($map($CallWithMetadata, $ex))
291291
else
292292
# [(R -> R)(R) ....]
293293
need_scalarize = true
294-
ex = :($Sym{Array{$FnType{Tuple, $type}, $ndim}}($var_name))
294+
ex = :($_Sym(Array{$FnType{Tuple, $type}, $ndim}, $var_name))
295295
ex = :($setmetadata($ex, $ArrayShapeCtx, ($(indices...),)))
296296
:($map($CallWith(($(call_args...),)), $ex))
297297
end

test/arrays.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ Symbolics.option_to_metadata_type(::Val{:test_meta}) = TestMetaT
2222
B = A[3:5]
2323
@test axes(B) == (Slice(1:3),)
2424

25-
i = Sym{Int}(:i)
26-
j = Sym{Int}(:j)
25+
i = _Sym(Int, :i)
26+
j = _Sym(Int, :j)
2727
@test symtype(X[i, j]) == Real
2828
@test symtype(X[1, j]) == Real
2929

test/overloads.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ vars = @variables t $a $b(t) $c(t)[1:3]
1111
@test b === :value_b
1212
@test c === :value_c
1313
@test isequal(vars[1], t)
14-
@test isequal(vars[2], Num(Sym{Real}(a)))
15-
@test isequal(vars[3], Num(Sym{FnType{Tuple{Any},Real}}(b)(value(t))))
14+
@test isequal(vars[2], Num(_Sym(Real, a)))
15+
@test isequal(vars[3], Num(_Sym(FnType{Tuple{Any},Real}, b)(value(t))))
1616

1717
vars = @variables a,b,c,d,e,f,g,h,i
1818
@test isequal(vars, [a,b,c,d,e,f,g,h,i])

0 commit comments

Comments
 (0)