The problem seems to be a mis-match between the way 1.0sโs type is displayed and the type obtained by typing it as a literal. Specifically, s is Unitful.Unit{:Second, Unitful.๐}(0,1) and not a another FreeUnits type (note that Unitful.s is a Unitful.FreeUnits{(s,), ๐, nothing} type and thus just typing s or Unitful.s will not get the parameter of typeof(1.0s) right)
The culprit here is are overloads of show in Unitful
function show(io::IO, x::Unit{N,D}) where {N,D}
show(io, FreeUnits{(x,), D, nothing}())
end
in conjunction with
function show(io::IO, x::Unitlike)
showoperators = get(io, :showoperators, false)
first = ""
sep = showoperators ? "*" : " "
foreach(sortexp(typeof(x).parameters[1])) do y
print(io,first)
showrep(io,y)
first = sep
end
nothing
end
which will make Unitful.Unit{:Second, ๐}(0, 1//1) print as s.
Question is, why are you comparing types this way? Iโd imagine itโd be more robust to check unit and dimension. But then again, isnโt a major point of working with units needing not to care about units?
Iโve found Julia types can get very long, especially when using Unitful.jl. There seems to be two things competing: having the information from show be accurate (you can copy-paste it and get the same quantity) and having it show something readable and informative. I donโt know what the best solution is, but Iโve gotten some truly nightmarish types when combining AxisArrays and Unitful.