Skip to content

Commit ba1ddf2

Browse files
Merge pull request #1220 from lamorton/vector2
Fixes #1218 issue with get_unit(Vector{Num}).
2 parents 0c6c628 + e4a2d69 commit ba1ddf2

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/systems/validation.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ end
2020
equivalent(x,y) = isequal(1*x,1*y)
2121
unitless = Unitful.unit(1)
2222

23+
get_unit(x::AbstractArray) = map(get_unit,x)
2324
get_unit(x::Num) = get_unit(value(x))
2425
function get_unit(x::Symbolic)
2526
if x isa Sym || operation(x) isa Sym || (operation(x) isa Term && operation(x).f == getindex) || x isa Symbolics.ArrayOp

test/units.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,16 @@ eqs =
206206
[
207207
D(x) ~ IfElse.ifelse(t>0.1,2,1)
208208
]
209-
@named sys = ODESystem(eqs, t, vars, [])
209+
@named sys = ODESystem(eqs, t, vars, [])
210+
211+
#Vectors of symbols
212+
@parameters t
213+
@register dummy(vector::Vector{Num}, scalar)
214+
dummy(vector, scalar) = vector[1] .- scalar
215+
216+
@variables vec[1:2](t)
217+
vec = collect(vec)
218+
eqs = [vec .~ dummy(vec, vec[1]);]
219+
sts = vcat(vec)
220+
ODESystem(eqs, t, [sts...;], [], name=:sys)
221+

0 commit comments

Comments
 (0)