[issue28328] statistics.geometric_mean has no tests. Defer to 3.7?

INADA Naoki report at bugs.python.org
Mon Oct 3 06:57:39 EDT 2016


INADA Naoki added the comment:

I run attached test, and saw following errors.

On macOS 10.11 (XCode 8)

$ hg summary
parent: 104258:0d948a46c59a
 test_invalid_sequences seems don't have to stay in CAPITest.
branch: 3.6
commit: 1 modified, 1 unknown
update: (current)


$ ./python.exe -m test.test_statistics -v
...
======================================================================
ERROR: test_negative_error (__main__.TestGeometricMean) (values=[-1])
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/inada-n/work/python/py36/Lib/test/test_statistics.py", line 1741, in test_negative_error
    self.assertRaises(exc, self.func, values)
  File "/Users/inada-n/work/python/py36/Lib/unittest/case.py", line 728, in assertRaises
    return context.handle('assertRaises', args, kwargs)
  File "/Users/inada-n/work/python/py36/Lib/unittest/case.py", line 177, in handle
    callable_obj(*args, **kwargs)
  File "/Users/inada-n/work/python/py36/Lib/statistics.py", line 567, in geometric_mean
    if isinstance(g, (numbers.Real, Decimal)):
NameError: name 'g' is not defined

======================================================================
ERROR: test_single_value (__main__.TestGeometricMean)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/inada-n/work/python/py36/Lib/test/test_statistics.py", line 1587, in test_single_value
    self.assertEqual(self.func([x]), x)
  File "/Users/inada-n/work/python/py36/Lib/statistics.py", line 567, in geometric_mean
    if isinstance(g, (numbers.Real, Decimal)):
NameError: name 'g' is not defined

======================================================================
ERROR: test_singleton_lists (__main__.TestGeometricMean)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/inada-n/work/python/py36/Lib/test/test_statistics.py", line 1762, in test_singleton_lists
    self.assertEqual(self.func([x]), x)
  File "/Users/inada-n/work/python/py36/Lib/statistics.py", line 567, in geometric_mean
    if isinstance(g, (numbers.Real, Decimal)):
NameError: name 'g' is not defined

======================================================================
FAIL: test_multiply_data_points (__main__.TestGeometricMean)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/inada-n/work/python/py36/Lib/test/test_statistics.py", line 1796, in test_multiply_data_points
    self.assertApproxEqual(self.func(data), expected, rel=1e-13)
  File "/Users/inada-n/work/python/py36/Lib/test/test_statistics.py", line 227, in assertApproxEqual
    check(first, second, tol, rel, msg)
  File "/Users/inada-n/work/python/py36/Lib/test/test_statistics.py", line 247, in _check_approx_num
    raise self.failureException(msg)
AssertionError:   6.27015835359916 != 695.9875772495068
  values differ by more than tol=0 and rel=1e-13
  -> absolute error = 689.7174188959076
  -> relative error = 0.990990990990991

----------
nosy: +inada.naoki

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


More information about the Python-bugs-list mailing list