-
Notifications
You must be signed in to change notification settings - Fork 114
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
Should the Quantity
constructor always return a Quantity
?
#584
Comments
IMO the current behaviour of the value * uparse(units) However, due to the behaviour of julia> typeof(1.0 * uparse("mg/dL"))
Quantity{Float64, 𝐌 𝐋⁻³, Unitful.FreeUnits{(mg, dL⁻¹), 𝐌 𝐋⁻³, nothing}}
julia> typeof(1.0 * uparse("L/L"))
Float64 The return type of "L/L" (units of hematocrit in the project) meant that suddenly the parsed server responses were incompatible with downstream |
I wouldn’t call it a bug (the behavior is intentional) and I certainly don’t think we should change it in a patch release. I think of this as a breaking change, something to do for Unitful v2.0.
Note that, even if it would return a |
I think it's a bug because the
This is exactly what I think it should return and what my downstream applications would require - a |
Currently,
Quantity(x, NoUnits)
just returnsx
. One needs to call the constructor with type parameters to actually get a quantity:I would argue that the
Quantity
constructor should always return aQuantity
(unless it errors, of course). There is a proposal for Julia 2.0 to enforce this for all constructors: JuliaLang/julia#42372.The text was updated successfully, but these errors were encountered: