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

Use threadpool for finding labels in chunk #327

Merged
merged 13 commits into from
May 2, 2024
Prev Previous commit
Next Next commit
Add threshold
  • Loading branch information
dcherian committed Jan 21, 2024
commit 7e8e717423c5be35636fb4cadc394955c4c74180
3 changes: 2 additions & 1 deletion flox/core.py
Original file line number Diff line number Diff line change
@@ -260,7 +260,8 @@ def chunk_unique(labels, slicer, nlabels, label_is_present=None):
uniques = ilabels[label_is_present[:-1]]
return uniques

if nlabels < approx_chunk_size:
if nlabels < 5 * approx_chunk_size:
logger.debug("Using threadpool since %s < 5 * %s", nlabels, approx_chunk_size)
with ThreadPoolExecutor() as executor:
futures = [
executor.submit(chunk_unique, labels, slicer, nlabels)
Loading