-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversion fails to strip variable #697
Comments
If you want to strip units you have to do that explicitly with |
That doesn't seem to match the expected behavior described here: https://docs.julialang.org/en/v1/manual/conversion-and-promotion/ One would expect at least that |
That what? I suggested |
I quote :
|
I'm missing what you're trying to say: julia> using Unitful
julia> convert(Float64, 1u"m")
ERROR: DimensionError: and m are not dimensionally compatible.
Again, if you want to get a dimensionless number out of a number with units, use |
I think that most people will run into this issue in Packages that have Unitful.jl as a dependency, such as PhysicalConstants.jl : they would expect the constants from the package to be drop-in replacements for whatever hardcoded constants they have in their code, but they run into this behavior which brakes the abstraction. |
Running this snippet
raises
ERROR: DimensionError: and m s^-1 are not dimensionally compatible.
It is my understanding that this comes from the fact that
Float64(c_0)
returns aUnitful.Quantity{Float64, 𝐋 𝐓 ^-1, Unitful.FreeUnits{(m, s^-1), 𝐋 𝐓 ^-1, nothing}}
instead of a Float64.I don't think this should be the expected behavior and in such a case the variable should be stripped of its unit.
The text was updated successfully, but these errors were encountered: