|
15 | 15 | # This is required to infer the right type for
|
16 | 16 | # Operation(Variable{Parameter{Number}}(:foo), [])
|
17 | 17 | # While keeping the metadata that the variable is a parameter.
|
18 |
| -SymbolicUtils.promote_symtype(f::SymbolicUtils.Variable{FnType{X,Parameter{Y}}}, |
| 18 | +SymbolicUtils.promote_symtype(f::SymbolicUtils.Sym{FnType{X,Parameter{Y}}}, |
19 | 19 | xs...) where {X, Y} = Y
|
20 | 20 |
|
21 | 21 | SymbolicUtils.arguments(x::Operation) = x.args
|
22 | 22 |
|
23 | 23 | # SymbolicUtils wants raw numbers
|
24 | 24 | SymbolicUtils.to_symbolic(x::Constant) = x.value
|
25 |
| -SymbolicUtils.to_symbolic(x::Variable{T}) where {T} = SymbolicUtils.Variable{T}(x.name) |
| 25 | +SymbolicUtils.to_symbolic(x::Variable{T}) where {T} = SymbolicUtils.Sym{T}(x.name) |
26 | 26 |
|
27 | 27 | # Optional types of vars
|
28 | 28 | # Once converted to SymbolicUtils Variable, a Parameter needs to hide its metadata
|
29 | 29 | _vartype(x::Variable{<:Parameter{T}}) where {T} = T
|
30 | 30 | _vartype(x::Variable{T}) where {T} = T
|
31 | 31 | SymbolicUtils.symtype(x::Variable) = _vartype(x) # needed for a()
|
32 |
| -SymbolicUtils.symtype(x::SymbolicUtils.Variable{<:Parameter{T}}) where {T} = T |
| 32 | +SymbolicUtils.symtype(x::SymbolicUtils.Sym{<:Parameter{T}}) where {T} = T |
33 | 33 |
|
34 | 34 | # returning Any causes SymbolicUtils to infer the type using `promote_symtype`
|
35 | 35 | # But we are OK with Number here for now I guess
|
|
44 | 44 |
|
45 | 45 | to_mtk(x) = x
|
46 | 46 | to_mtk(x::Number) = Constant(x)
|
47 |
| -to_mtk(v::SymbolicUtils.Variable{T}) where {T} = Variable{T}(nameof(v)) |
48 |
| -to_mtk(v::SymbolicUtils.Variable{FnType{X,Y}}) where {X,Y} = Variable{Y}(nameof(v)) |
| 47 | +to_mtk(v::SymbolicUtils.Sym{T}) where {T} = Variable{T}(nameof(v)) |
| 48 | +to_mtk(v::SymbolicUtils.Sym{FnType{X,Y}}) where {X,Y} = Variable{Y}(nameof(v)) |
49 | 49 | function to_mtk(expr::SymbolicUtils.Term)
|
50 | 50 | Operation(to_mtk(SymbolicUtils.operation(expr)),
|
51 | 51 | map(to_mtk, SymbolicUtils.arguments(expr)))
|
|
0 commit comments