-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add missing Base.similar(::QuantityArray, ...)
definition
#95
Conversation
Benchmark Results
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
map(x -> x^2, QuantityArray([0.5u"m"]))
|
Fixed! julia> qa = fill(1.5u"m", 3)
3-element QuantityArray(::Vector{Float64}, ::Quantity{Float64, Dimensions{DynamicQuantities.FixedRational{Int32, 25200}}}):
1.5 m
1.5 m
1.5 m
julia> map(x -> x^2, qa)
3-element QuantityArray(::Vector{Float64}, ::Quantity{Float64, Dimensions{DynamicQuantities.FixedRational{Int32, 25200}}}):
2.25 m²
2.25 m²
2.25 m² |
I guess my one worry is whether calling |
2345185
to
1ebe408
Compare
4b5075d
to
4af667b
Compare
49a5165
to
1f2c1a5
Compare
8f87e2f
to
13c7e4b
Compare
Unittests done. Once you are content with this @jkrumbiegel we could merge this. (Although I think I might need to add some extra unittests to get coverage on the other branches of |
c184b7e
to
0f567e2
Compare
0cd028d
to
3d392d7
Compare
Since this is a pretty nasty bug that the current errors are not useful for (stack overflow errors, etc.), I'm going to go ahead and merge now with a self-review. But let me know if anybody has comments and we can implement changes later! |
Fixes #93 #94 by @jkrumbiegel.
All it turned out to be was a missing method
which is used in the standard lib for some of the array operations.
The method I had written had mistakenly assumed the
::Type
here was the numeric eltype, likeFloat64
. But in retrospect it was perhaps obvious that this would be the quantity type, because, after all,QuantityArray
is anAbstractArray{Q,N}
whereQ
is a quantity type.Let me know if this works for you @jkrumbiegel
I also added a
::Q
type assertion to prevent stack overflows related to converting a quantity of a quantity to a quantity.We should probably implement a constructor for quantities of quantities that throws an error or simply converts to a regular quantity...