Skip to content

Commit 3e5ede6

Browse files
committed
rework docs a bit; add partitioned_factory to top level namespace
1 parent 1b0682d commit 3e5ede6

File tree

4 files changed

+55
-26
lines changed

4 files changed

+55
-26
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ instance/
8989

9090
# Sphinx documentation
9191
docs/_build/
92+
docs/generated/
9293

9394
# PyBuilder
9495
target/

docs/api.rst

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,23 @@ Collection API
55
^^^^^^^^^^^^^^
66

77
.. currentmodule:: dask_histogram
8+
89
.. autosummary::
10+
:toctree: generated/
11+
912
AggHistogram
1013
PartitionedHistogram
1114
factory
15+
partitioned_factory
1216

1317
dask.array/NumPy-like API
1418
^^^^^^^^^^^^^^^^^^^^^^^^^
1519

1620
.. currentmodule:: dask_histogram.routines
21+
1722
.. autosummary::
23+
:toctree: generated/
24+
1825
histogram
1926
histogram2d
2027
histogramdd
@@ -23,27 +30,31 @@ boost-histogram-like API
2330
^^^^^^^^^^^^^^^^^^^^^^^^
2431

2532
.. currentmodule:: dask_histogram.boost
26-
.. autosummary::
27-
Histogram
2833

29-
Reference
30-
^^^^^^^^^
31-
32-
.. currentmodule:: dask_histogram
33-
.. autofunction:: factory
34-
.. autoclass:: AggHistogram
35-
:members:
36-
:autosummary:
37-
.. autoclass:: PartitionedHistogram
38-
:members:
39-
:autosummary:
34+
.. autosummary::
35+
:toctree: generated/
4036

41-
.. currentmodule:: dask_histogram.routines
42-
.. autofunction:: histogram
43-
.. autofunction:: histogram2d
44-
.. autofunction:: histogramdd
37+
Histogram
4538

46-
.. currentmodule:: dask_histogram.boost
47-
.. autoclass:: Histogram
48-
:members:
49-
:autosummary:
39+
..
40+
Reference
41+
^^^^^^^^^
42+
43+
.. currentmodule:: dask_histogram
44+
.. autofunction:: factory
45+
.. autoclass:: AggHistogram
46+
:members:
47+
:autosummary:
48+
.. autoclass:: PartitionedHistogram
49+
:members:
50+
:autosummary:
51+
52+
.. currentmodule:: dask_histogram.routines
53+
.. autofunction:: histogram
54+
.. autofunction:: histogram2d
55+
.. autofunction:: histogramdd
56+
57+
.. currentmodule:: dask_histogram.boost
58+
.. autoclass:: Histogram
59+
:members:
60+
:autosummary:

src/dask_histogram/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
import boost_histogram.axis as _axis
44
import boost_histogram.storage as _storage
55

6-
from dask_histogram.core import AggHistogram, PartitionedHistogram, factory
6+
from dask_histogram.core import (
7+
AggHistogram,
8+
PartitionedHistogram,
9+
factory,
10+
partitioned_factory,
11+
)
712
from dask_histogram.routines import histogram, histogram2d, histogramdd
813
from dask_histogram.version import __version__
914

@@ -27,5 +32,6 @@
2732
"histogram",
2833
"histogram2d",
2934
"histogramdd",
35+
"partitioned_factory",
3036
"storage",
3137
)

src/dask_histogram/core.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ def _partitioned_histogram(
617617
) -> PartitionedHistogram:
618618
name = f"hist-on-block-{tokenize(data, histref, weights, sample, split_every)}"
619619
data_is_df = is_dataframe_like(data[0])
620-
data_is_dak = is_awkward_like(data[0])
620+
data_is_dak = is_dask_awkward_like(data[0])
621621
_weight_sample_check(*data, weights=weights)
622622

623623
# Single awkward array object.
@@ -832,8 +832,7 @@ def factory(
832832
split_every : int, optional
833833
How many blocks to use in each split during aggregation.
834834
keep_partitioned : bool, optional
835-
If ``True``, return the partitioned histogram collection
836-
instead of an aggregated histogram.
835+
**Deprecated argument**. Use :py:func:`partitioned_factory`.
837836
838837
Returns
839838
-------
@@ -911,6 +910,18 @@ def partitioned_factory(
911910
weights: DaskCollection | None = None,
912911
sample: DaskCollection | None = None,
913912
) -> PartitionedHistogram:
913+
"""Daskified Histogram collection factory function; keep partitioned.
914+
915+
This is a version of the :py:func:`factory` function that **remains
916+
partitioned**. The :py:func:`factory` function includes a step in the
917+
task graph that aggregates all partitions into a single final
918+
histogram.
919+
920+
See Also
921+
--------
922+
dask_histogram.factory
923+
924+
"""
914925
if histref is None and axes is None:
915926
raise ValueError("Either histref or axes must be defined.")
916927
if histref is not None and storage is not None:
@@ -925,7 +936,7 @@ def partitioned_factory(
925936
)
926937

927938

928-
def is_awkward_like(x: Any) -> bool:
939+
def is_dask_awkward_like(x: Any) -> bool:
929940
"""Check if an object is Awkward collection like.
930941
931942
Parameters

0 commit comments

Comments
 (0)