Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fix in creation of loopchunks #397

Merged
merged 1 commit into from
May 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading