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

Make unfilled computed hist pickleable #154

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion src/dask_histogram/boost.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,13 @@ def __dask_tokenize__(self) -> str:
return self.dask_name

def __dask_postcompute__(self) -> Any:
return lambda x: self._in_memory_type(first(x)), ()
def f(x):
out = self._in_memory_type(first(x))
if hasattr(out, "_dask"):
del out._dask
return out

return f, ()

def __dask_postpersist__(self) -> Any:
return self._rebuild, ()
Expand Down
14 changes: 14 additions & 0 deletions tests/test_boost.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,3 +553,17 @@ def test_histref_pickle():
h1.fill(x) # forces the internal state histref update

pickle.dumps(h1._histref)


def test_boost_output_pickles():
import pickle

import boost_histogram
import dask

import dask_histogram.boost

h = dask_histogram.boost.Histogram(boost_histogram.axis.Regular(10, 0, 1))

o = dask.compute(h)
pickle.dumps(o)
Loading