@@ -3,30 +3,30 @@ Base.:*(x::Union{Num,Symbolic},y::Unitful.AbstractQuantity) = x * y
3
3
4
4
function vartype (x:: Symbolic )
5
5
if ! (x. metadata isa Nothing)
6
- return haskey (x. metadata,VariableUnit) ? x. metadata[VariableUnit] : 1.0
6
+ return haskey (x. metadata, VariableUnit) ? x. metadata[VariableUnit] : 1
7
7
end
8
- 1.0
8
+ 1
9
9
end
10
10
vartype (x:: Num ) = vartype (value (x))
11
11
12
- instantiate (x) = 1.0
12
+ instantiate (x) = 1
13
13
instantiate (x:: Num ) = instantiate (value (x))
14
14
function instantiate (x:: Symbolic )
15
15
vx = value (x)
16
16
if vx isa Sym || operation (vx) isa Sym
17
- return oneunit (1 * ModelingToolkit. vartype (x))
18
17
elseif operation (vx) isa Differential
18
+ return oneunit (1 * vartype (vx))
19
19
return instantiate (arguments (vx)[1 ]) / instantiate (arguments (arguments (vx)[1 ])[1 ])
20
20
elseif vx isa Pow
21
21
pargs = arguments (vx)
22
22
base,expon = instantiate .(pargs)
23
23
uconvert (NoUnits, expon) # This acts as an assertion
24
- return base == 1.0 ? 1.0 : operation (vx)(base, pargs[2 ])
24
+ return base == 1 ? 1 : operation (vx)(base, pargs[2 ])
25
25
elseif vx isa Add # Cannot simply add the units b/c they may differ in magnitude (eg, kg vs g)
26
26
terms = instantiate .(arguments (vx))
27
27
firstunit = unit (terms[1 ])
28
28
@assert all (map (x -> ustrip (firstunit, x) == 1 , terms[2 : end ]))
29
- return 1.0 * firstunit
29
+ return 1 * firstunit
30
30
else
31
31
return oneunit (operation (vx)(instantiate .(arguments (vx))... ))
32
32
end
0 commit comments