8000 DOC: unambiguous np.histogram dtype description (#25520) · numpy/numpy@448e4da · GitHub
[go: up one dir, main page]

Skip to content

Commit 448e4da

Browse files
authored
DOC: unambiguous np.histogram dtype description (#25520)
* DOC: unambiguous np.histogram dtype description As a follow-up of #25403, let's be more specific than "dictates the dtype" because that could still mean that there is a mapping applied such as weights uint8 -> acc uint64, weights float -> acc double, ... That would make so much sense that people could expect that and thus read it into the documentation, I am afraid.
1 parent 8e8da65 commit 448e4da

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

numpy/lib/_histograms_impl.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,9 @@ def histogram(a, bins=10, range=None, density=None, weights=None):
711711
(instead of 1). If `density` is True, the weights are
712712
normalized, so that the integral of the density over the range
713713
remains 1.
714-
Please note that the ``dtype`` of `weights` will dictate the
715-
``dtype`` of the returned accumulator (`hist`).
714+
Please note that the ``dtype`` of `weights` will also become the
715+
``dtype`` of the returned accumulator (`hist`), so it must be
716+
large enough to hold accumulated values as well.
716717
density : bool, optional
717718
If ``False``, the result will contain the number of samples in
718719
each bin. If ``True``, the result is the value of the
@@ -725,7 +726,8 @@ def histogram(a, bins=10, range=None, density=None, weights=None):
725726
-------
726727
hist : array
727728
The values of the histogram. See `density` and `weights` for a
728-
description of the possible semantics.
729+
description of the possible semantics. If `weights` are given,
730+
``hist.dtype`` will be taken from `weights`.
729731
bin_edges : array of dtype float
730732
Return the bin edges ``(length(hist)+1)``.
731733

0 commit comments

Comments
 (0)
0