-
-
Notifications
You must be signed in to change notification settings - Fork 74
Add docs page for subpackages #563
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
Merged
ChrisRackauckas
merged 2 commits into
SciML:master
from
ChrisRackauckas-Claude:add-subpackage-docs
Apr 1, 2026
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| # Subpackages | ||
|
|
||
| RecursiveArrayTools.jl ships several optional subpackages under `lib/`. Each is a | ||
| separate Julia package that adds functionality which was split out of the main | ||
| package to avoid method invalidations that would increase load times for users who | ||
| don't need that functionality. | ||
|
|
||
| ## RecursiveArrayToolsRaggedArrays | ||
|
|
||
| True ragged (non-rectangular) array types that preserve exact structure without | ||
| zero-padding. See the [Ragged Arrays](@ref) page for full documentation. | ||
|
|
||
| ```julia | ||
| using RecursiveArrayToolsRaggedArrays | ||
| ``` | ||
|
|
||
| ## RecursiveArrayToolsShorthandConstructors | ||
|
|
||
| Shorthand `VA[...]` and `AP[...]` constructor syntax for `VectorOfArray` and | ||
| `ArrayPartition`. | ||
|
|
||
| This is separated from the main package because the `getindex(::Type, ...)` method | ||
| definitions invalidate compiled specializations of `Base.getindex(::Type{T}, vals...)` | ||
| from Base, increasing load times for downstream packages that don't need the syntax. | ||
|
|
||
| ```julia | ||
| using RecursiveArrayToolsShorthandConstructors | ||
| ``` | ||
|
|
||
| ### Usage | ||
|
|
||
| ```julia | ||
| using RecursiveArrayTools | ||
| using RecursiveArrayToolsShorthandConstructors | ||
|
|
||
| # VectorOfArray shorthand (equivalent to VectorOfArray([[1,2,3], [4,5,6]])) | ||
| u = VA[[1, 2, 3], [4, 5, 6], [7, 8, 9]] | ||
|
|
||
| # ArrayPartition shorthand (equivalent to ArrayPartition(x0, v0, a0)) | ||
| x0, v0, a0 = rand(3, 3), rand(3, 3), rand(3, 3) | ||
| u0 = AP[x0, v0, a0] | ||
| u0.x[1] === x0 # true | ||
|
|
||
| # Nesting works | ||
| nested = VA[fill(1, 2, 3), VA[3ones(3), zeros(3)]] | ||
| ``` | ||
|
|
||
| Without this package, use the equivalent explicit constructors: | ||
|
|
||
| ```julia | ||
| u = VectorOfArray([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) | ||
| u0 = ArrayPartition(x0, v0, a0) | ||
| ``` | ||
|
|
||
| ## RecursiveArrayToolsArrayPartitionAnyAll | ||
|
|
||
| Optimized `any` and `all` for `ArrayPartition` that iterate partition-by-partition | ||
| instead of element-by-element, giving ~1.5-1.8x speedup on full scans. | ||
|
|
||
| This is separated from the main package because `any(f::Function, ::ArrayPartition)` | ||
| invalidates ~780 compiled specializations of `any(f::Function, ::AbstractArray)`. | ||
|
|
||
| ```julia | ||
| using RecursiveArrayToolsArrayPartitionAnyAll | ||
| ``` | ||
|
|
||
| ### Usage | ||
|
|
||
| ```julia | ||
| using RecursiveArrayTools | ||
| using RecursiveArrayToolsArrayPartitionAnyAll | ||
|
|
||
| ap = ArrayPartition(rand(1000), rand(1000), rand(1000)) | ||
|
|
||
| # These now use the optimized partition-by-partition iteration | ||
| any(isnan, ap) # ~1.5x faster than default | ||
| all(x -> x > 0, ap) # ~1.8x faster than default | ||
| ``` | ||
|
|
||
| Without this package, `any`/`all` use the default `AbstractArray` implementation | ||
| which is correct but slower due to per-element partition indexing overhead. | ||
|
|
||
| ### Why is it faster? | ||
|
|
||
| `ArrayPartition` stores data as a tuple of arrays. The default `AbstractArray` | ||
| `any`/`all` iterates element-by-element, which requires computing which partition | ||
| each linear index falls into. The optimized methods iterate over each partition | ||
| array directly, avoiding that lookup overhead entirely. | ||
|
|
||
| ## Installation | ||
|
|
||
| All subpackages can be installed from the monorepo: | ||
|
|
||
| ```julia | ||
| using Pkg | ||
| Pkg.add(url = "https://github.com/SciML/RecursiveArrayTools.jl", | ||
| subdir = "lib/RecursiveArrayToolsRaggedArrays") | ||
| Pkg.add(url = "https://github.com/SciML/RecursiveArrayTools.jl", | ||
| subdir = "lib/RecursiveArrayToolsShorthandConstructors") | ||
| Pkg.add(url = "https://github.com/SciML/RecursiveArrayTools.jl", | ||
| subdir = "lib/RecursiveArrayToolsArrayPartitionAnyAll") | ||
| ``` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.