-
Notifications
You must be signed in to change notification settings - Fork 17
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
Particles & Unitful #152
Comments
It seems you're creating an object with the wrong type, see |
Thanks, I saw that part, just not sure how to apply it in my case. julia> function f(x) # simple MWE for f
y = 123u"m" * x
ustrip(u"cm", x*y)
end
julia> x = Particles() # create an plain non-unitful particles
8.88178e-19 ± 1.0 Particles{Float64, 2000}
julia> f(x) # apply f to x, expecting to get just Particles{Float64, 2000}:
-1.2e-16 ± 1.3e-13 ± 9810.0 ± 7400.0 Particles{Particles{Float64, 2000}, 2000} |
The issue is probably some missing methods in the unitful extension. The multiplication *(x::AbstractQuantity, y::Number) in Unitful, instead of function Base.$f(y::Quantity{S,D,U}, p::$PT{T,N}) where {S, D, U, T <: Quantity, N}
QT = Base.promote_op($op, typeof(y), T)
$PT{QT,N}($(op).(y, p.particles))
end in MCM.jl due to the Try out and see if that works out for you, if it does, I'll make a new release |
I noticed that sometimes mixing units and MCM particles results in weird results – nesting two levels of Particles, resulting in 2000*2000 floats underneath:
I wonder how to avoid/fix that?
The text was updated successfully, but these errors were encountered: