You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am experimenting with Unitful parametric types to force a particular unit in a struct or function. I am having trouble getting it to work, and in my experimenting, I discovered the following result:
The result of the typeof(1.0u"cm^-3") is not equal to typeof(1.0u"cm^-3"), at least for the example above. In my struct, if I use typeof(1.0u"cm^-3") as the type, I can use the constructor of the struct. But, when I use the result of typeof(1.0u"cm^-3"), I get the following error:
ERROR: MethodError: no method matching Quantity{#s92495,𝐋^-3,cm^-3} where #s92495<:Real(::Quantity{Int64,𝐋^-3,Unitful.FreeUnits{(cm^-3,),𝐋^-3,nothing}})
Just to add some information that has since been added to the Discourse thread, the difference is that although the printed representation is the same, the cm in the third type parameter is not the same as Unitful.cm:
I am experimenting with Unitful parametric types to force a particular unit in a struct or function. I am having trouble getting it to work, and in my experimenting, I discovered the following result:
The result of the
typeof(1.0u"cm^-3")
is not equal totypeof(1.0u"cm^-3")
, at least for the example above. In my struct, if I usetypeof(1.0u"cm^-3")
as the type, I can use the constructor of the struct. But, when I use the result oftypeof(1.0u"cm^-3")
, I get the following error:There is a discourse discussion started on this:
https://discourse.julialang.org/t/how-to-properly-use-unitful/40295
The text was updated successfully, but these errors were encountered: