|
1 |
| -function Base.convert(::Type{<:Array}, ss::AbstractArray{<:ShiftedAbstractArray{<:Any, N}}, I::Vararg{<:AbstractArray, N}) where N |
| 1 | +""" |
| 2 | +`to_array(ss::AbstractArray{<:AbstractArray{<:Any, N}}, I::Vararg{<:AbstractArray, N}) where N` |
| 3 | +
|
| 4 | +Collect a `AbstractArray` of `AbstractArrays` into a normal `Array` selecting indices `I` (can take negative values if inner `AbstractArrays` allow it). |
| 5 | +The output `Array` first few dimensions will be indexed by `I` (though starting from `1`) |
| 6 | +and the last one will correspond to the index of the inner `AbstractArray` within the `AbstractArray` of `AbstractArrays`. |
| 7 | +""" |
| 8 | +function to_array(ss::AbstractArray{<:AbstractArray{<:Any, N}}, I::Vararg{<:AbstractArray, N}) where N |
2 | 9 | v = VectorOfArray([view(s, I...) for s in ss])
|
3 | 10 | Array(v)
|
4 | 11 | end
|
5 | 12 |
|
6 |
| -function Base.convert(::Type{<:OffsetArray}, ss::AbstractArray{<:ShiftedAbstractArray{<:Any, N}}, I::Vararg{<:AbstractArray, N}) where N |
7 |
| - m = convert(Array, ss, I...) |
| 13 | +""" |
| 14 | +`to_offsetarray(ss::AbstractArray{<:AbstractArray{<:Any, N}}, I::Vararg{<:AbstractArray, N}) where N` |
| 15 | +
|
| 16 | +Collect a `AbstractArray` of `ShiftedArrays` into an `OffsetArray` selecting indices `I` (can take negative values if inner `AbstractArrays` allow it). |
| 17 | +The output `OffsetArray` first few dimensions will be indexed by `I` |
| 18 | +and the last one will correspond to the index of the inner `AbstractArray` within the `AbstractArray` of `AbstractArrays`. |
| 19 | +""" |
| 20 | +function to_offsetarray(ss::AbstractArray{<:AbstractArray{<:Any, N}}, I::Vararg{<:AbstractArray, N}) where N |
| 21 | + m = to_array(ss, I...) |
8 | 22 | OffsetArray(m, I..., last(Compat.axes(m)))
|
9 | 23 | end
|
0 commit comments