Skip to content

Commit

Permalink
Merge pull request #156 from dask-contrib/fix-dh-factory
Browse files Browse the repository at this point in the history
fix: dask_histogram.factory broken after dask 2024.12
  • Loading branch information
lgray authored Dec 17, 2024
2 parents 8920ec8 + d3cb1a1 commit bf85767
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/dask_histogram/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,15 +1027,8 @@ def _partitioned_histogram(
if len(data) == 1 and data_is_dak:
from dask_awkward.lib.core import partitionwise_layer as dak_pwl

x = data[0]
if weights is not None and sample is not None:
g = dak_pwl(_blocked_dak, name, x, weights, sample, histref=histref)
elif weights is not None and sample is None:
g = dak_pwl(_blocked_dak, name, x, weights, None, histref=histref)
elif weights is None and sample is not None:
g = dak_pwl(_blocked_dak, name, x, None, sample, histref=histref)
else:
g = dak_pwl(_blocked_dak, name, x, None, None, histref=histref)
f = partial(_blocked_dak, weights=weights, sample=sample, histref=histref)
g = dak_pwl(f, name, data[0])

# Single object, not a dataframe
elif len(data) == 1 and not data_is_df:
Expand Down
17 changes: 17 additions & 0 deletions tests/test_boost.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,3 +567,20 @@ def test_boost_output_pickles():

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


def test_155_boost_factory():
import boost_histogram as bh

dak = pytest.importorskip("dask_awkward")
import numpy as np

import dask_histogram as dh

arr = dak.from_lists([list(range(10))] * 3)
axis = bh.axis.Regular(10, 0.0, 10.0)
hist = dh.factory(
arr,
axes=(axis,),
).compute()
assert np.all(hist.values() == [3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0])

0 comments on commit bf85767

Please sign in to comment.