File tree Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -82,24 +82,24 @@ function safe_get_unit(term, info)
82
82
end
83
83
84
84
function _validate (terms:: Vector , labels:: Vector{String} ; info:: String = " " )
85
- equnits = safe_get_unit .(terms, info* " " .* labels)
86
- allthere = all (map (x -> x!= = nothing , equnits))
87
- allmatching = true
85
+ valid = true
88
86
first_unit = nothing
89
- if allthere
90
- for idx in 1 : length (equnits)
91
- if ! isequal (terms[idx],0 )
92
- if first_unit === nothing
93
- first_unit = equnits[idx]
94
- elseif ! equivalent (first_unit, equnits[idx])
95
- allmatching = false
96
- @warn (" $info : units [$(equnits[1 ]) ] for $(labels[1 ]) and [$(equnits[idx]) ] for $(labels[idx]) do not match." )
97
-
98
- end
87
+ first_label = nothing
88
+ for (term,label) in zip (terms,labels)
89
+ equnit = safe_get_unit (term, info* label)
90
+ if equnit === nothing
91
+ valid = false
92
+ elseif ! isequal (term,0 )
93
+ if first_unit === nothing
94
+ first_unit = equnit
95
+ first_label = label
96
+ elseif ! equivalent (first_unit, equnit)
97
+ valid = false
98
+ @warn (" $info : units [$(equnit) ] for $(first_label) and [$(equnit) ] for $(label) do not match." )
99
99
end
100
100
end
101
101
end
102
- allthere && allmatching
102
+ valid
103
103
end
104
104
105
105
function validate (jump:: Union{ModelingToolkit.VariableRateJump, ModelingToolkit.ConstantRateJump} , t:: Symbolic ; info:: String = " " )
You can’t perform that action at this time.
0 commit comments