Skip to content

Commit 9f5ef9d

Browse files
authored
Merge pull request #48 from lgray/fill_typetracer_handling
Allow _blocked_dak and _blocked_dak_ma to deal with typetracers
2 parents ed59b2b + 863c797 commit 9f5ef9d

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/dask_histogram/core.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,26 @@ def _blocked_df_w_s(
192192

193193

194194
def _blocked_dak(data: Any, *, histref: bh.Histogram | None = None) -> bh.Histogram:
195-
return clone(histref).fill(data)
195+
import awkward as ak
196+
197+
thedata = data
198+
if isinstance(thedata, ak.Array) and ak.backend(thedata) == "typetracer":
199+
thedata.layout._touch_data(recursive=True)
200+
thedata = data.layout.form.length_zero_array()
201+
202+
return clone(histref).fill(thedata)
196203

197204

198205
def _blocked_dak_ma(*data: Any, histref: bh.Histogram | None = None) -> bh.Histogram:
199-
return clone(histref).fill(*data)
206+
import awkward as ak
207+
208+
thedata = list(data)
209+
for idata, adatum in enumerate(thedata):
210+
if isinstance(adatum, ak.Array) and ak.backend(adatum) == "typetracer":
211+
adatum.layout._touch_data(recursive=True)
212+
thedata[idata] = adatum.layout.form.length_zero_array()
213+
214+
return clone(histref).fill(*tuple(thedata))
200215

201216

202217
def optimize(

0 commit comments

Comments
 (0)