|
1 | 1 | """ |
2 | | - PermutedDiskArray <: AbstractDiskArray |
| 2 | + AbstractPermutedDiskArray <: AbstractDiskArray |
| 3 | +
|
| 4 | +Abstract supertype for diskarray with permuted dimensions. |
| 5 | +""" |
| 6 | +abstract type AbstractPermutedDiskArray{T,N,P<:PermutedDimsArray{T,N}} <: AbstractDiskArray{T,N} end |
| 7 | + |
| 8 | +""" |
| 9 | + PermutedDiskArray <: AbstractPermutedDiskArray |
3 | 10 |
|
4 | 11 | A lazily permuted disk array returned by `permutedims(diskarray, permutation)`. |
5 | 12 | """ |
6 | | -struct PermutedDiskArray{T,N,P<:PermutedDimsArray{T,N}} <: AbstractDiskArray{T,N} |
| 13 | +struct PermutedDiskArray{T,N,P<:PermutedDimsArray{T,N}} <: AbstractPermutedDiskArray{T,N,P} |
7 | 14 | a::P |
8 | 15 | end |
9 | 16 |
|
10 | 17 | # Base methods |
11 | | - |
12 | | -Base.size(a::PermutedDiskArray) = size(a.a) |
13 | | - |
| 18 | +Base.size(a::AbstractPermutedDiskArray) = size(a.a) |
| 19 | +Base.parent(a::AbstractPermutedDiskArray) = a.a.parent |
14 | 20 | # DiskArrays interface |
15 | 21 |
|
16 | | -haschunks(a::PermutedDiskArray) = haschunks(a.a.parent) |
17 | | -function eachchunk(a::PermutedDiskArray) |
| 22 | +haschunks(a::AbstractPermutedDiskArray) = haschunks(parent(a)) |
| 23 | +function eachchunk(a::AbstractPermutedDiskArray) |
18 | 24 | # Get the parent chunks |
19 | | - gridchunks = eachchunk(a.a.parent) |
20 | | - perm = _getperm(a.a) |
| 25 | + gridchunks = eachchunk(parent(a)) |
| 26 | + perm = _getperm(a) |
21 | 27 | # Return permuted GridChunks |
22 | 28 | return GridChunks(genperm(gridchunks.chunks, perm)...) |
23 | 29 | end |
24 | | -function DiskArrays.readblock!(a::PermutedDiskArray, aout, i::OrdinalRange...) |
| 30 | +function DiskArrays.readblock!(a::AbstractPermutedDiskArray, aout, i::OrdinalRange...) |
25 | 31 | iperm = _getiperm(a) |
26 | 32 | # Permute the indices |
27 | 33 | inew = genperm(i, iperm) |
28 | 34 | # Permute the dest block and read from the true parent |
29 | | - DiskArrays.readblock!(a.a.parent, PermutedDimsArray(aout, iperm), inew...) |
| 35 | + DiskArrays.readblock!(parent(a), PermutedDimsArray(aout, iperm), inew...) |
30 | 36 | return nothing |
31 | 37 | end |
32 | | -function DiskArrays.writeblock!(a::PermutedDiskArray, v, i::OrdinalRange...) |
| 38 | +function DiskArrays.writeblock!(a::AbstractPermutedDiskArray, v, i::OrdinalRange...) |
33 | 39 | iperm = _getiperm(a) |
34 | 40 | inew = genperm(i, iperm) |
35 | 41 | # Permute the dest block and write from the true parent |
36 | | - DiskArrays.writeblock!(a.a.parent, PermutedDimsArray(v, iperm), inew...) |
| 42 | + DiskArrays.writeblock!(parent(a), PermutedDimsArray(v, iperm), inew...) |
37 | 43 | return nothing |
38 | 44 | end |
39 | 45 |
|
40 | | -_getperm(a::PermutedDiskArray) = _getperm(a.a) |
| 46 | +_getperm(a::AbstractPermutedDiskArray) = _getperm(a.a) |
41 | 47 | _getperm(::PermutedDimsArray{<:Any,<:Any,perm}) where {perm} = perm |
42 | 48 |
|
43 | | -_getiperm(a::PermutedDiskArray) = _getiperm(a.a) |
| 49 | +_getiperm(a::AbstractPermutedDiskArray) = _getiperm(a.a) |
44 | 50 | _getiperm(::PermutedDimsArray{<:Any,<:Any,<:Any,iperm}) where {iperm} = iperm |
45 | 51 |
|
46 | 52 | # Implementaion macros |
|
0 commit comments