@@ -22,18 +22,16 @@ function ConcatDiskArray(arrays::AbstractArray{<:AbstractArray{<:Any,N},M}) wher
22
22
T = mapreduce (eltype, promote_type, init= eltype (first (arrays)), arrays)
23
23
24
24
if N > M
25
- newshape = extenddims (size (arrays), size (first (arrays)))
26
- @show newshape
25
+ newshape = extenddims (size (arrays), size (first (arrays)),1 )
27
26
arrays1 = reshape (arrays, newshape)
28
27
D = N
29
28
else
30
29
arrays1 = arrays
31
30
D = M
32
31
end
33
32
startinds, sizes = arraysize_and_startinds (arrays1)
34
- @show startinds, sizes
35
33
36
- chunks = concat_chunksize (D, arrays1)
34
+ chunks = concat_chunksize (arrays1)
37
35
hc = Chunked (batchstrategy (chunks))
38
36
39
37
return ConcatDiskArray {T,D,typeof(arrays1),typeof(chunks),typeof(hc)} (arrays1, startinds, sizes, chunks, hc)
@@ -44,8 +42,8 @@ function ConcatDiskArray(arrays::AbstractArray)
44
42
error (" Arrays don't have the same dimensions" )
45
43
return error (" Should not be reached" )
46
44
end
47
- extenddims (a:: NTuple{N,Int } ,b:: NTuple{M,Int} ) where {N,M} = extenddims ((a... ,1 ), b)
48
- extenddims (a:: NTuple{N,Int} ,b :: NTuple{N,Int} ) where {N} = a
45
+ extenddims (a:: NTuple{N} ,b:: NTuple{M} ,fillval ) where {N,M} = extenddims ((a... ,fillval ), b, fillval )
46
+ extenddims (a:: NTuple{N} ,_ :: NTuple{N} ,_ ) where {N} = a
49
47
50
48
Base. size (a:: ConcatDiskArray ) = a. size
51
49
@@ -113,15 +111,24 @@ function _concat_diskarray_block_io(f, a::ConcatDiskArray, inds...)
113
111
end
114
112
end
115
113
116
- function concat_chunksize (N, parents)
117
- oldchunks = map (eachchunk, parents)
118
- newchunks = ntuple (N) do i
119
- sliceinds = Base. setindex (ntuple (_ -> 1 , N), :, i)
120
- v = map (c -> c. chunks[i], oldchunks[sliceinds... ])
114
+ function concat_chunksize (parents)
115
+ newchunks = map (s-> Vector {Union{RegularChunks, IrregularChunks}} (undef, s) ,size (parents))
116
+ for i in CartesianIndices (parents)
117
+ array = parents[i]
118
+ chunks = eachchunk (array)
119
+ foreach (chunks. chunks,i. I,newchunks) do c, ind, newc
120
+ if ! isassigned (newc, ind)
121
+ newc[ind] = c
122
+ elseif c != newc[ind]
123
+ throw (ArgumentError (" Chunk sizes don't forma grid" ))
124
+ end
125
+ end
126
+ end
127
+ newchunks = map (newchunks) do v
121
128
init = RegularChunks (approx_chunksize (first (v)), 0 , 0 )
122
129
reduce (mergechunks, v; init= init)
123
130
end
124
-
131
+ extenddims (newchunks, size (parents), RegularChunks ( 1 , 0 , 1 ))
125
132
return GridChunks (newchunks... )
126
133
end
127
134
0 commit comments