Skip to content

Commit d2823c0

Browse files
committed
Added docstrings and AbstractArrayPartition type
After @ChrisRackauckas comments I have documented how to subtype from AbstractNamedArrayPartition as well as added an AbstractArrayPartition type which both AbstractNamedArrayPartition and ArrayPartition subtype from
1 parent b7d264c commit d2823c0

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/array_partition.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
abstract type AbstractArrayPartition{T} <: AbstractVector{T} end
2+
13
"""
24
```julia
35
ArrayPartition(x::AbstractArray...)
@@ -23,7 +25,7 @@ A = ArrayPartition(y, z)
2325
2426
we would have `A.x[1]==y` and `A.x[2]==z`. Broadcasting like `f.(A)` is efficient.
2527
"""
26-
struct ArrayPartition{T, S <: Tuple} <: AbstractVector{T}
28+
struct ArrayPartition{T, S <: Tuple} <: AbstractArrayPartition{T}
2729
x::S
2830
end
2931

src/named_array_partition.jl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
abstract type AbstractNamedArrayPartition{T, A, NT} <: AbstractVector{T} end
1+
"""
2+
AbstractNamedArrayPartition{T, A, NT}
3+
4+
An abstract type above that of `NamedArrayPartition` that can be used to subtype a
5+
new and seperately named 'NamedArrayPartition'-like structure. This can be done
6+
by defining your new type as:
7+
8+
```julia
9+
struct foo{T, A <: ArrayPartition{T}, NT <: NamedTuple} <: AbstractNamedArrayPartition{T, A, NT}
10+
array_partition::A
11+
names_to_indices::NT
12+
end
13+
```
14+
15+
where `foo` is your custom name and then all funcitonalities of NamedArrayPartitions will be inherited.
16+
"""
17+
abstract type AbstractNamedArrayPartition{T, A, NT} <: AbstractArrayPartition{T} end
218

319
"""
420
NamedArrayPartition(; kwargs...)

0 commit comments

Comments
 (0)