-
Notifications
You must be signed in to change notification settings - Fork 25
Additional QuantityArray
constructions
#178
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
base: main
Are you sure you want to change the base?
Conversation
QuantityArray
constructions
Benchmark Results (Julia v1.10)Time benchmarks
Memory benchmarks
|
Benchmark Results (Julia v1)Time benchmarks
Memory benchmarks
|
Hi @MilesCranmer, this PR should be ready for your review now. Two follow-up questions I had were:
|
Sweet, looks like this is working nicely with the new Makie PR: julia> using CairoMakie, DynamicQuantities
julia> x = [6, 7, 8]us"cm"
3-element QuantityArray(::Vector{Float64}, ::Quantity{Float64, SymbolicDimensions{FixedRational{Int32, 25200}}}):
6.0 cm
7.0 cm
8.0 cm
julia> y = (4:6)u"kg"
3-element QuantityArray(::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, ::Quantity{Float64, Dimensions{FixedRational{Int32, 25200}}}):
4.0 kg
5.0 kg
6.0 kg
julia> scatter(x, y) ![]() |
Actually, think I found a good balance, just pushed. Does this look alright to you? |
@@ -364,6 +364,22 @@ julia> @btime $f.(qa) setup=(xa = randn(100000) .* u"km/s"; qa = QuantityArray(x | |||
|
|||
So we can see the `QuantityArray` version saves on both time and memory. | |||
|
|||
By default, DynamicQuantities will create a `QuantityArray` from an `AbstractArray`, similarly to how a `Quantity` is created from a scalar in the [Usage](@ref) examples: | |||
|
|||
```@repl quantity-array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
```@repl quantity-array | |
```julia |
Since it will primarily be read via the README directly on github. Though maybe there could be a preprocessing stage before Documenter.jl build?
|
||
This can be overridden to produce a vector of `Quantity`s by explicitly broadcasting the unit: | ||
|
||
```@repl quantity-array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
```@repl quantity-array | |
```julia |
@@ -281,6 +282,8 @@ f_square(v) = v^2 * 1.5 - v^2 | |||
println("Applying function to y_q: ", sum(f_square.(y_q))) | |||
``` | |||
|
|||
See [Home > Arrays](@ref home_arrays) for more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this ref work btw?
@@ -0,0 +1,482 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this file got mistakenly committed. It is generated during the Documenter build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thanks for this and sorry for the delay. I only had a couple requests
Also re: your question, I think creating from generators is probably too much for now. |
Closes #166
To-do