Skip to content

Commit 3b334ae

Browse files
author
Lucas Morton
committed
More verbose warning to help pinpoint unit errors.
1 parent 7c38479 commit 3b334ae

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/systems/validation.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ function get_units(x::Symbolic)
2222
elseif x isa Add # Cannot simply add the units b/c they may differ in magnitude (eg, kg vs g)
2323
terms = get_units.(arguments(x))
2424
firstunit = unit(terms[1])
25-
@assert all(map(x -> ustrip(firstunit, x) == 1, terms[2:end]))
25+
for other in terms[2:end]
26+
unit(other) == firstunit || throw(ArgumentError("Units mismatch: [$x] with units [$terms]."))
27+
end
2628
return 1 * firstunit
2729
elseif operation(x) == Symbolics._mapreduce
2830
if x.arguments[2] == +

0 commit comments

Comments
 (0)