Skip to content

Commit

Permalink
small fix in creation of loopchunks (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
meggart authored May 28, 2024
1 parent 7a80fe5 commit 5afbfb9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/DAT/DAT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,14 @@ function makeinplace(f)
end
end

to_chunksize(c::RegularChunks, cs, _ = true) = RegularChunks(cs, c.offset, c.s)
function to_chunksize(c::RegularChunks, cs, _ = true)
offset = if c.cs==cs
c.offset
else
0
end
RegularChunks(cs, offset, c.s)
end
function to_chunksize(c::IrregularChunks, cs, allow_irregular=true)
fac = cs ÷ approx_chunksize(c)
ll = length.(c)
Expand Down Expand Up @@ -545,8 +552,9 @@ function getloopchunks(dc::DATConfig)
ii === nothing ? nothing : eachchunk(ic.cube.data).chunks[ii]
end
allchunks = unique(filter(!isnothing, allchunks))

if length(allchunks) == 1
return to_chunksize(allchunks[1],cs,dc.allow_irregular_chunks)
return to_chunksize(only(allchunks),cs,dc.allow_irregular_chunks)
end
allchunks_offset = filter(i->mod(cs,approx_chunksize(i))==0, allchunks)
allchunks = isempty(allchunks_offset) ? allchunks : allchunks_offset
Expand Down

0 comments on commit 5afbfb9

Please sign in to comment.