[New-bugs-announce] [issue25177] OverflowError in statistics.mean when summing large floats

David MacIver report at bugs.python.org
Sat Sep 19 13:40:40 CEST 2015


New submission from David MacIver:

The following code produces an OverflowError:

import statistics
statistics.mean([8.988465674311579e+307, 8.98846567431158e+307])

The error is:

  File "/home/david/.pyenv/versions/3.5.0/lib/python3.5/statistics.py", line 293, in mean
    return _sum(data)/n
  File "/home/david/.pyenv/versions/3.5.0/lib/python3.5/statistics.py", line 184, in _sum
    return T(total)
  File "/home/david/.pyenv/versions/3.5.0/lib/python3.5/numbers.py", line 291, in __float__
    return self.numerator / self.denominator
OverflowError: integer division result too large for a float


If this is intended behaviour then it is not documented: https://docs.python.org/3/library/statistics.html#statistics.mean only specifies that it may raise StatisticsError.

----------
components: Library (Lib)
messages: 251076
nosy: David MacIver
priority: normal
severity: normal
status: open
title: OverflowError in statistics.mean when summing large floats
versions: Python 3.4, Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25177>
_______________________________________


More information about the New-bugs-announce mailing list