You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a situation where I kick off N tasks, and the nth task processes the nth chunk of several different collections. In some collections, the nth chunk might not exist, because the collection is shorter than n. Currently I have to write a wrapper function to avoid throwing an error in this case, as follows:
functionithchunk(N, taskid, collection)
c =index_chunks(collection; n=N)
returnview(collection, taskid <=length(c) ? c[taskid] :1:0)
end
However, if ChunkSplitters supported a minsize=0, such that N chunks were always returned, some of them being empty, then I could simply write:
and be certain that this wouldn't throw an error for any taskid <= N. This could avoid any potential type instability resulting from the ternary operator in my wrapper function.
Maybe it would be more consistent if we had defined that the chunks is always equal to n, returning empty chunks if the minsize option was not set. Changing that now would be breaking and I'm not sure if worth the trouble.
The only complication of minsize=0 is what is the type of the empty chunks, and the consequences of inheriting the type of the other chunks. I'm not sure if that can cause instabilities in some contexts.
Activity
lmiq commentedon Jun 27, 2026
Two points:
Maybe it would be more consistent if we had defined that the chunks is always equal to
n, returning empty chunks if theminsizeoption was not set. Changing that now would be breaking and I'm not sure if worth the trouble.The only complication of
minsize=0is what is the type of the empty chunks, and the consequences of inheriting the type of the other chunks. I'm not sure if that can cause instabilities in some contexts.