Skip to content

Commit f2c91b5

Browse files
authored
Merge pull request #154 from dask-contrib/bare_pickle
Make unfilled computed hist pickleable
2 parents 8923899 + ab8e5ac commit f2c91b5

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/dask_histogram/boost.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,13 @@ def __dask_tokenize__(self) -> str:
137137
return self.dask_name
138138

139139
def __dask_postcompute__(self) -> Any:
140-
return lambda x: self._in_memory_type(first(x)), ()
140+
def f(x):
141+
out = self._in_memory_type(first(x))
142+
if hasattr(out, "_dask"):
143+
del out._dask
144+
return out
145+
146+
return f, ()
141147

142148
def __dask_postpersist__(self) -> Any:
143149
return self._rebuild, ()

tests/test_boost.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,3 +553,17 @@ def test_histref_pickle():
553553
h1.fill(x) # forces the internal state histref update
554554

555555
pickle.dumps(h1._histref)
556+
557+
558+
def test_boost_output_pickles():
559+
import pickle
560+
561+
import boost_histogram
562+
import dask
563+
564+
import dask_histogram.boost
565+
566+
h = dask_histogram.boost.Histogram(boost_histogram.axis.Regular(10, 0, 1))
567+
568+
o = dask.compute(h)
569+
pickle.dumps(o)

0 commit comments

Comments
 (0)