Skip to content

Commit 6b66dc3

Browse files
bpo-38382: Document the early-out behavior for a zero (GH-17037) (GH-17078)
(cherry picked from commit 7f46049) Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
1 parent 30da387 commit 6b66dc3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Doc/library/statistics.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ However, for reading convenience, most of the examples show sorted sequences.
164164
The harmonic mean, sometimes called the subcontrary mean, is the
165165
reciprocal of the arithmetic :func:`mean` of the reciprocals of the
166166
data. For example, the harmonic mean of three values *a*, *b* and *c*
167-
will be equivalent to ``3/(1/a + 1/b + 1/c)``.
167+
will be equivalent to ``3/(1/a + 1/b + 1/c)``. If one of the values
168+
is zero, the result will be zero.
168169

169170
The harmonic mean is a type of average, a measure of the central
170171
location of the data. It is often appropriate when averaging
@@ -190,6 +191,10 @@ However, for reading convenience, most of the examples show sorted sequences.
190191
:exc:`StatisticsError` is raised if *data* is empty, or any element
191192
is less than zero.
192193

194+
The current algorithm has an early-out when it encounters a zero
195+
in the input. This means that the subsequent inputs are not tested
196+
for validity. (This behavior may change in the future.)
197+
193198
.. versionadded:: 3.6
194199

195200

0 commit comments

Comments
 (0)