-
Notifications
You must be signed in to change notification settings - Fork 38
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
Feature Request: Allow for More Flexible Unitful.jl Constructions #35
Comments
You can achieve what you'd like with the following definitions: using Measurements, Unitful
function Measurements.measurement(a::T, b::T) where {T<:Quantity}
u = unit(a)
return measurement(ustrip(u, a), ustrip(u, b)) * u
end
Measurements.measurement(a::Quantity{T1,D,U1}, b::Quantity{T2,D,U2}) where {T1,T2,D,U1,U2} =
measurement(promote(a, b)...) E.g. julia> quantity = 1.3km ± 2.01μm
1300.0 ± 2.01e-6 m However I'm not going to add this feature because I don't wont to depend on |
I don't see why this couldn't be added as an optional function if |
Yesterday I started playing to see if this feasible without using Unitful.jl: https://github.com/JuliaPhysics/Measurements.jl/tree/unitful. However I won't have much time to continue this experiment before next week |
This isn't really straightforward without using some magic. One possible magic is using the |
I think it would be great if it were possible to write:
instead of
The Julia REPL says that it would require a
measurement(::Quantity, ::Quantity)
function.The text was updated successfully, but these errors were encountered: