Skip to content
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

Multiplication with particles from Unitful.jl #81

Closed
jonniedie opened this issue May 27, 2020 · 5 comments
Closed

Multiplication with particles from Unitful.jl #81

jonniedie opened this issue May 27, 2020 · 5 comments

Comments

@jonniedie
Copy link

Seeing that this worked:

julia> (1 ± 0.5)m * (1 ± 0)kg
Part10000(1.0 kg m ± 0.4999920218301007 kg m)

I was hoping that this would work, but it doesn't

julia> (1 ± 0.5)m * 1kg
ERROR: DimensionError: kg and 0.586026044547503 kg m are not dimensionally compatible.
Stacktrace:
 [1] convert(::Type{Quantity{Quantity{Float64,D,U} where U where D,�,Unitful.FreeUnits{(kg,),�,nothing}}}, ::Quantity{Float64,�*�,Unitful.FreeUnits{(kg, m),�*�,nothing}}) at C:\Users\jdiegelm\.julia\packages\Unitful\dZYmO\src\conversion.jl:108
 [2] setindex!(::Array{Quantity{Quantity{Float64,D,U} where U where D,�,Unitful.FreeUnits{(kg,),�,nothing}},1}, ::Quantity{Float64,�*�,Unitful.FreeUnits{(kg, m),�*�,nothing}}, ::Int64) at .\array.jl:825
 [3] copyto! at .\multidimensional.jl:962 [inlined]
 [4] Array{Quantity{Quantity{Float64,D,U} where U where D,�,Unitful.FreeUnits{(kg,),�,nothing}},1}(::Array{Quantity{Float64,�*�,Unitful.FreeUnits{(kg, m),�*�,nothing}},1}) at .\array.jl:541
 [5] convert at .\array.jl:533 [inlined]
 [6] Particles at C:\Users\jdiegelm\.julia\packages\MonteCarloMeasurements\FcMud\src\types.jl:18 [inlined]
 [7] *(::Particles{Quantity{Float64,�,Unitful.FreeUnits{(m,),�,nothing}},10000}, ::Quantity{Int64,�,Unitful.FreeUnits{(kg,),�,nothing}}) at C:\Users\jdiegelm\.julia\packages\MonteCarloMeasurements\FcMud\src\unitful.jl:28
 [8] top-level scope at REPL[23]:1

Not sure if this is a MonteCarloMeasurements.jl issue or a Unitful.jl issue, so I thought I'd put it here.

@baggepinnen
Copy link
Owner

Thanks for the report. It's probably a missing promotion method that needs to be added. I've never used Unitful myself so the support for this is not that well battle tested.

@baggepinnen
Copy link
Owner

The Unitful stuff is here
https://github.com/baggepinnen/MonteCarloMeasurements.jl/blob/master/src/unitful.jl
If you figure it out, feel free to add the missing method, if not, I'll get to it in the morning.

@baggepinnen
Copy link
Owner

This should be solved on master, I'll tag a new release as soon as tests have passed :)

@baggepinnen
Copy link
Owner

@jonniedie
Copy link
Author

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants