[issue28111] geometric_mean can raise OverflowError when checking for inf

2016-09-16 Thread Mark Dickinson

Mark Dickinson added the comment:

See msg276732 in issue 27761 for a possible solution.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28111] geometric_mean can raise OverflowError when checking for inf

2016-09-13 Thread Mark Dickinson

Mark Dickinson added the comment:

For reference, here's the full traceback. Issue #27975 isn't relevant here - 
the problem is an out-of-range integer being passed to the math.pow operation.

taniyama:cpython-git mdickinson$ ./python.exe
Python 3.7.0a0 (default, Sep 13 2016, 08:36:28) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import statistics
>>> statistics.geometric_mean(0.7 for _ in range(5000))
Traceback (most recent call last):
  File "/Users/mdickinson/Python/cpython-git/Lib/statistics.py", line 343, in 
float_nroot
isinfinity = math.isinf(x)
OverflowError: int too large to convert to float

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 1, in 
  File "/Users/mdickinson/Python/cpython-git/Lib/statistics.py", line 578, in 
geometric_mean
s = 2**p * _nth_root(2**q, n)
  File "/Users/mdickinson/Python/cpython-git/Lib/statistics.py", line 330, in 
nth_root
return _nroot_NS.float_nroot(x, n)
  File "/Users/mdickinson/Python/cpython-git/Lib/statistics.py", line 345, in 
float_nroot
return _nroot_NS.bignum_nroot(x, n)
  File "/Users/mdickinson/Python/cpython-git/Lib/statistics.py", line 472, in 
bignum_nroot
b = 2**q * _nroot_NS.nroot(2**r, n)
  File "/Users/mdickinson/Python/cpython-git/Lib/statistics.py", line 365, in 
nroot
r1 = math.pow(x, 1.0/n)
OverflowError: int too large to convert to float

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28111] geometric_mean can raise OverflowError when checking for inf

2016-09-12 Thread Steven D'Aprano

New submission from Steven D'Aprano:

>>> statistics.geometric_mean([0.7 for _ in range(5000)])
Traceback (most recent call last):
  File "/Users/mdickinson/Python/cpython-git/Lib/statistics.py", line 362, in 
float_nroot
isinfinity = math.isinf(x)
OverflowError: int too large to convert to float

See #27975 and #27181

--
assignee: steven.daprano
components: Library (Lib)
messages: 276149
nosy: haypo, mark.dickinson, steven.daprano
priority: normal
severity: normal
status: open
title: geometric_mean can raise OverflowError when checking for inf
type: behavior
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com