Skip to content

Commit a4be06f

Browse files
authored
Update docstrings (#432)
1 parent 1b58ad1 commit a4be06f

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

flox/core.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2293,7 +2293,7 @@ def groupby_reduce(
22932293
*by : ndarray or DaskArray
22942294
Array of labels to group over. Must be aligned with ``array`` so that
22952295
``array.shape[-by.ndim :] == by.shape`` or any disagreements in that
2296-
equality check are for dimensions of size 1 in `by`.
2296+
equality check are for dimensions of size 1 in ``by``.
22972297
func : {"all", "any", "count", "sum", "nansum", "mean", "nanmean", \
22982298
"max", "nanmax", "min", "nanmin", "argmax", "nanargmax", "argmin", "nanargmin", \
22992299
"quantile", "nanquantile", "median", "nanmedian", "mode", "nanmode", \
@@ -2308,33 +2308,34 @@ def groupby_reduce(
23082308
reductions when ``method`` is not ``"map-reduce"``. For ``"map-reduce"``, the groups
23092309
are always sorted.
23102310
axis : None or int or Sequence[int], optional
2311-
If None, reduce across all dimensions of by
2312-
Else, reduce across corresponding axes of array
2313-
Negative integers are normalized using array.ndim
2311+
If None, reduce across all dimensions of ``by``,
2312+
else reduce across corresponding axes of array.
2313+
Negative integers are normalized using ``array.ndim``.
23142314
fill_value : Any
23152315
Value to assign when a label in ``expected_groups`` is not present.
23162316
dtype : data-type , optional
23172317
DType for the output. Can be anything that is accepted by ``np.dtype``.
23182318
min_count : int, default: None
23192319
The required number of valid values to perform the operation. If
2320-
fewer than min_count non-NA values are present the result will be
2321-
NA. Only used if skipna is set to True or defaults to True for the
2320+
fewer than ``min_count`` non-NA values are present the result will be
2321+
NA. Only used if ``skipna`` is set to True or defaults to True for the
23222322
array's dtype.
23232323
method : {"map-reduce", "blockwise", "cohorts"}, optional
2324+
Note that this arg is chosen by default using heuristics.
23242325
Strategy for reduction of dask arrays only:
23252326
* ``"map-reduce"``:
23262327
First apply the reduction blockwise on ``array``, then
23272328
combine a few newighbouring blocks, apply the reduction.
23282329
Continue until finalizing. Usually, ``func`` will need
2329-
to be an Aggregation instance for this method to work.
2330+
to be an ``Aggregation`` instance for this method to work.
23302331
Common aggregations are implemented.
23312332
* ``"blockwise"``:
23322333
Only reduce using blockwise and avoid aggregating blocks
23332334
together. Useful for resampling-style reductions where group
2334-
members are always together. If `by` is 1D, `array` is automatically
2335+
members are always together. If ``by`` is 1D, ``array`` is automatically
23352336
rechunked so that chunk boundaries line up with group boundaries
23362337
i.e. each block contains all members of any group present
2337-
in that block. For nD `by`, you must make sure that all members of a group
2338+
in that block. For nD ``by``, you must make sure that all members of a group
23382339
are present in a single block.
23392340
* ``"cohorts"``:
23402341
Finds group labels that tend to occur together ("cohorts"),

flox/xarray.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def xarray_reduce(
8080
reindex: bool | None = None,
8181
**finalize_kwargs,
8282
):
83-
"""GroupBy reduce operations on xarray objects using numpy-groupies
83+
"""GroupBy reduce operations on xarray objects using numpy-groupies.
8484
8585
Parameters
8686
----------
@@ -105,26 +105,27 @@ def xarray_reduce(
105105
dim : hashable
106106
dimension name along which to reduce. If None, reduces across all
107107
dimensions of `by`
108-
fill_value
108+
fill_value : Any
109109
Value used for missing groups in the output i.e. when one of the labels
110110
in ``expected_groups`` is not actually present in ``by``.
111111
dtype : data-type, optional
112-
DType for the output. Can be anything accepted by ``np.dtype``.
112+
DType for the output. Can be anything that is accepted by ``np.dtype``.
113113
method : {"map-reduce", "blockwise", "cohorts"}, optional
114+
Note that this arg is chosen by default using heuristics.
114115
Strategy for reduction of dask arrays only:
115116
* ``"map-reduce"``:
116117
First apply the reduction blockwise on ``array``, then
117118
combine a few newighbouring blocks, apply the reduction.
118119
Continue until finalizing. Usually, ``func`` will need
119-
to be an Aggregation instance for this method to work.
120+
to be an ``Aggregation`` instance for this method to work.
120121
Common aggregations are implemented.
121122
* ``"blockwise"``:
122123
Only reduce using blockwise and avoid aggregating blocks
123124
together. Useful for resampling-style reductions where group
124-
members are always together. If `by` is 1D, `array` is automatically
125+
members are always together. If ``by`` is 1D, ``array`` is automatically
125126
rechunked so that chunk boundaries line up with group boundaries
126127
i.e. each block contains all members of any group present
127-
in that block. For nD `by`, you must make sure that all members of a group
128+
in that block. For nD ``by``, you must make sure that all members of a group
128129
are present in a single block.
129130
* ``"cohorts"``:
130131
Finds group labels that tend to occur together ("cohorts"),
@@ -134,11 +135,11 @@ def xarray_reduce(
134135
'month', dayofyear' etc. Optimize chunking ``array`` for this
135136
method by first rechunking using ``rechunk_for_cohorts``
136137
(for 1D ``by`` only).
137-
engine : {"flox", "numpy", "numba"}, optional
138+
engine : {"flox", "numpy", "numba", "numbagg"}, optional
138139
Algorithm to compute the groupby reduction on non-dask arrays and on each dask chunk:
139140
* ``"numpy"``:
140141
Use the vectorized implementations in ``numpy_groupies.aggregate_numpy``.
141-
This is the default choice because it works for other array types.
142+
This is the default choice because it works for most array types.
142143
* ``"flox"``:
143144
Use an internal implementation where the data is sorted so that
144145
all members of a group occur sequentially, and then numpy.ufunc.reduceat
@@ -162,13 +163,13 @@ def xarray_reduce(
162163
NA. Only used if skipna is set to True or defaults to True for the
163164
array's dtype.
164165
reindex : bool, optional
165-
Whether to "reindex" the blockwise results to `expected_groups` (possibly automatically detected).
166+
Whether to "reindex" the blockwise results to ``expected_groups`` (possibly automatically detected).
166167
If True, the intermediate result of the blockwise groupby-reduction has a value for all expected groups,
167168
and the final result is a simple reduction of those intermediates. In nearly all cases, this is a significant
168169
boost in computation speed. For cases like time grouping, this may result in large intermediates relative to the
169-
original block size. Avoid that by using method="cohorts". By default, it is turned off for arg reductions.
170-
**finalize_kwargs
171-
kwargs passed to the finalize function, like ``ddof`` for var, std or ``q`` for quantile.
170+
original block size. Avoid that by using ``method="cohorts"``. By default, it is turned off for argreductions.
171+
**finalize_kwargs : dict, optional
172+
Kwargs passed to finalize the reduction such as ``ddof`` for var, std or ``q`` for quantile.
172173
173174
Returns
174175
-------

0 commit comments

Comments
 (0)