Skip to content

Commit df1ce60

Browse files
committed
typing
1 parent 433ee71 commit df1ce60

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

src/dask_histogram/boost.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def concrete_fill(
111111
)
112112
return super().fill(*args, weight=weight, sample=sample, threads=threads)
113113

114-
def fill(
114+
def fill( # type: ignore
115115
self,
116116
*args: DaskCollection,
117117
weight: DaskCollection | None = None,
@@ -193,7 +193,7 @@ def fill(
193193
if self._staged is not None:
194194
self._staged += new_fill
195195
else:
196-
self._staged = new_fill
196+
self._staged = new_fill # type: ignore
197197

198198
return self
199199

@@ -360,8 +360,8 @@ def to_dask_array(
360360
counts = da.from_array(counts)
361361
edges = [da.from_array(ea) for ea in edges] # type: ignore
362362
if dd:
363-
return counts, edges
364-
return tuple([counts, *edges])
363+
return counts, edges # type: ignore
364+
return tuple([counts, *edges]) # type: ignore
365365

366366

367367
def histogramdd(
@@ -375,7 +375,7 @@ def histogramdd(
375375
histogram: Any | None = None,
376376
storage: storage.Storage = storage.Double(),
377377
threads: int | None = None,
378-
) -> (Histogram | tuple[da.Array, ...] | tuple[da.Array, tuple[da.Array, ...]]):
378+
) -> Histogram | tuple[da.Array, ...] | tuple[da.Array, list[da.Array]]:
379379
"""Histogram Dask data in multiple dimensions.
380380
381381
Parameters
@@ -697,7 +697,7 @@ def histogram2d(
697697

698698
if histogram != Histogram:
699699
return hist.to_dask_array(flow=False, dd=False) # type: ignore
700-
return hist
700+
return hist # type: ignore
701701

702702

703703
def histogram(
@@ -794,4 +794,4 @@ def histogram(
794794

795795
if histogram != Histogram:
796796
return hist.to_dask_array(flow=False, dd=False) # type: ignore
797-
return hist
797+
return hist # type: ignore

src/dask_histogram/core.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def _rebuild(
253253
name = self._name
254254
if rename:
255255
name = rename.get(name, name)
256-
return type(self)(dsk, name, self.meta)
256+
return type(self)(dsk, name, self.histref)
257257

258258
@property
259259
def name(self) -> str:
@@ -312,7 +312,7 @@ def __setstate__(self, state: tuple[HighLevelGraph, str, bh.Histogram]) -> None:
312312

313313
def to_dask_array(
314314
self, flow: bool = False, dd: bool = False
315-
) -> tuple[da.Array, ...] | tuple[da.Array, tuple[da.Array, ...]]:
315+
) -> tuple[da.Array, ...] | tuple[da.Array, list[da.Array]]:
316316
"""Convert histogram object to dask.array form.
317317
318318
Parameters
@@ -468,7 +468,7 @@ def __str__(self) -> str:
468468

469469
@property
470470
def _args(self) -> tuple[HighLevelGraph, str, int, bh.Histogram]:
471-
return (self.dask, self.name, self.npartititions, self.histref)
471+
return (self.dask, self.name, self.npartitions, self.histref)
472472

473473
def __getstate__(self) -> tuple[HighLevelGraph, str, int, bh.Histogram]:
474474
return self._args
@@ -564,7 +564,7 @@ def _partitioned_histogram(
564564
weights: DaskCollection | None = None,
565565
sample: DaskCollection | None = None,
566566
split_every: int | None = None,
567-
) -> AggHistogram:
567+
) -> PartitionedHistogram:
568568
name = f"hist-on-block-{tokenize(data, histref, weights, sample)}"
569569
data_is_df = is_dataframe_like(data[0])
570570
_weight_sample_check(*data, weights=weights)
@@ -630,7 +630,7 @@ def to_dask_array(
630630
agghist: AggHistogram,
631631
flow: bool = False,
632632
dd: bool = False,
633-
) -> tuple[DaskCollection, list[DaskCollection]] | tuple[DaskCollection, ...]:
633+
) -> tuple[da.Array, ...] | tuple[da.Array, list[da.Array]]:
634634
"""Convert `agghist` to a `dask.array` return style.
635635
636636
Parameters
@@ -694,12 +694,12 @@ def __call__(self, a: AggHistogram, b: AggHistogram) -> AggHistogram:
694694
deps.append(a)
695695
k1 = a.name
696696
else:
697-
k1 = a
697+
k1 = a # type: ignore
698698
if is_dask_collection(b):
699699
deps.append(b)
700700
k2 = b.name
701701
else:
702-
k2 = b
702+
k2 = b # type: ignore
703703
k1 = a.__dask_tokenize__() if is_dask_collection(a) else a # type: ignore
704704
k2 = b.__dask_tokenize__() if is_dask_collection(b) else b # type: ignore
705705
llg = {name: (self.func, k1, k2)}
@@ -832,7 +832,7 @@ def factory(
832832
storage = bh.storage.Double()
833833
histref = bh.Histogram(*axes, storage=storage) # type: ignore
834834
f = _partitioned_histogram if keep_partitioned else _reduced_histogram
835-
return f(
835+
return f( # type: ignore
836836
*data,
837837
histref=histref,
838838
weights=weights,

src/dask_histogram/routines.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def histogram(
3232
histogram: Any | None = None,
3333
storage: bh.storage.Storage = bh.storage.Double(),
3434
threads: int | None = None,
35-
) -> AggHistogram | tuple[da.Array, ...]:
35+
) -> AggHistogram | tuple[da.Array, ...] | tuple[da.Array, list[da.Array]]:
3636
"""Histogram Dask data in one dimension.
3737
3838
Parameters
@@ -118,7 +118,7 @@ def histogram(
118118
)
119119
if histogram is None:
120120
return h.to_dask_array(flow=False, dd=False) # type: ignore
121-
return h
121+
return h # type: ignore
122122

123123

124124
def histogram2d(
@@ -241,7 +241,7 @@ def histogram2d(
241241
)
242242
if histogram is None:
243243
return h.to_dask_array(flow=False, dd=False) # type: ignore
244-
return h
244+
return h # type: ignore
245245

246246

247247
def histogramdd(
@@ -255,7 +255,7 @@ def histogramdd(
255255
histogram: Any | None = None,
256256
storage: bh.storage.Storage = bh.storage.Double(),
257257
threads: int | None = None,
258-
) -> (AggHistogram | tuple[da.Array, ...] | tuple[da.Array, tuple[da.Array, ...]]):
258+
) -> AggHistogram | tuple[da.Array, list[da.Array]]:
259259
"""Histogram Dask data in multiple dimensions.
260260
261261
Parameters
@@ -443,5 +443,5 @@ def histogramdd(
443443
ah = factory(*a, axes=axes, storage=storage, weights=weights)
444444

445445
if histogram is not None:
446-
return ah
447-
return ah.to_dask_array(flow=False, dd=True)
446+
return ah # type: ignore
447+
return ah.to_dask_array(flow=False, dd=True) # type: ignore

tests/test_core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import dask.array as da
55
import dask.array.utils as dau
66
import dask.datasets as dds
7-
import dask.delayed as delayed
87
import numpy as np
98
import pytest
9+
from dask.delayed import delayed
1010

1111
import dask_histogram.core as dhc
1212

@@ -152,7 +152,7 @@ def gen_hist_1D(
152152
range: tuple[float, float] = (-3, 3),
153153
size: tuple[int, ...] = (1000,),
154154
chunks: tuple[int, ...] = (250,),
155-
) -> dhc.AggHistogram:
155+
):
156156
hr = bh.Histogram(
157157
bh.axis.Regular(bins, range[0], range[1]),
158158
storage=bh.storage.Weight(),

0 commit comments

Comments
 (0)