-
Notifications
You must be signed in to change notification settings - Fork 9
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
[WIP] Improve ArrayOfSimilarArrays and VectorOfArrays (breaking) #20
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #20 +/- ##
=======================================
Coverage 95.78% 95.78%
=======================================
Files 7 7
Lines 451 451
=======================================
Hits 432 432
Misses 19 19 Continue to review full report at Codecov.
|
I would prefer if this would be solved language-wide with JuliaLang/julia#32310 and |
I'm looking forward to that PR getting merged a lot myself. Will that one also bring a generic equivalent to Still, JuliaLang/julia#32310 will not bring efficient vectors of similar matrices (e.g. to represent multiple samples of matrix-variate distributions) and so on, from what I understand. |
It will support them and more generally vectors of any higher-dimensional array - e.g. you can take a four-dimensional array and with |
It seems to me ArraysOfArrays and JuliaLang/julia#32310 offer very different kinds of abstractions. ArraysOfArrays gives a more efficient representation for an The PR seems to me more related to views. The user starts with an array, and can slice it in different ways. |
Hm, yes and no maybe - looking a bit deeper into , it looks like |
I've created #21 as a reminder regarding JuliaLang/julia#32310 . |
Here's a load time analysis of
So
Interestingly, the cost of using |
The load time of julia> using SnoopCompileCore
julia> invalidations = @snoopr using StatsBase
1106-element Vector{Any}: [...]
julia> invalidations = @snoopr using StaticArrays
273-element Vector{Any}: [...]
julia> invalidations = @snoopr using ArraysOfArrays
Any[] |
As expected, the timings show that Requires increases loading times in particular if the conditional dependencies are loaded. AFAIK this is a general observation with Requires. Some other problems are listed here: JuliaLang/Pkg.jl#1285 |
Indeed. And since the extra code activated here in that case is very compact, the overhead of using Requires compared to hard dependencies is relatively small in this case as well. |
Update: #26 has removed all requires. We have StaticArraysCore.jl now, and Julia v1.9 (and hopefully Compat.jl as well) will bring |
This PR is intended to accumulate breaking API changes for ArraysOfArrays v0.7 to address certain issues and add features required to support additional use cases.
Remove@require
s: @torfjelde and @cscherrer expressed interest to use ArraysOfArrays within the Turing (see Support InverseFunctions.jl and ChangesOfVariables.jl TuringLang/Bijectors.jl#199) and MeasureTheory ecosystems, but the fact that ArraysOfArrays currently uses Requires makes that option less attractive.ArrayOfSimilarArrays
was originally designed to represent vectors of vector-values samples (it originated within BAT.jl), so it would be a good fit.Update: #26 has removed all requires
SupportingStatsBase.mean
and friends with weights: If ArraysOfArrays can be made more lightweight, maybe it could become acceptable as a dependency for StatsBase. Semantically this would be nice, also for Distributions, sinceArrayOfSimilarArrays
resolved the confusion regarding which dimensions of a matrix are used for the "parameter" axis and the "n_th sample"-axis, with different defaults forrand
andcov
and so on. And things likeDistributions.likelihood
(already supports abstract vectors of vectors) could use fast matrix-backed implementations forArrayOfSimilarArrays
.Update: StatsBase should handle this, the upcoming
Base.AbstractSlices
will provide a basis for specialized statistics operations on sliced arrays.Supporting StaticArrays (usingnestedview
andflatview
for zero-copy switching between matrix and vector-of-StaticArray representation). StaticArrays isn't very lightweight, but while ArraysOfArrays is very lean, it's not a super-slim API-only package either (but still lighter than StaticArrays). Could StaticArrays depend on ArraysOfArrays in principle? - @andyferris, @timholy may I pull you in here?The new StaticArraysCore.jl allows us to support static arrays directly in ArraysOfArrays without heavy dependencies.
Append-to-element-vectors support for
VectorOfArrays
(a vector of non-similar arrays, a.k.a a "ragged array"), Support resizing of elements of VectorOfArrays #10: @mrVeng was missing the this ability. This can be done in an amortized fashion with a variant ofVectorOfArrays
(see https://discourse.julialang.org/t/elasticarrays-arraysofarrays-for-vector-of-arrays/70426/2). Theelem_ptr
vector will be replaced by a vector of ranges, the current behavior will be available via a customVectorOfContiguousRanges
type backed by what is currentlyelem_ptr
.Finally address issue getindex(.) return type does not match eltype #2 (CC @Moelf).