You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
statistics.geometric_mean has no tests. Defer to 3.7? #72515
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/stevendaprano'closed_at=<Date2019-02-21.06:25:11.553>created_at=<Date2016-10-01.12:33:54.610>labels= ['type-bug', '3.7']
title='statistics.geometric_mean has no tests. Defer to 3.7?'updated_at=<Date2019-02-21.06:25:11.552>user='https://github.com/mdickinson'
Steve, Ned: what do you think about taking geometric_mean out of Python 3.6, leaving us time to get it into shape for 3.7? The implementation of geometric_mean is complicated, with many edge cases. The original code was committed without review in bpo-27181, and it currently suffers from some serious bugs: see bpo-27761, bpo-28111, bpo-28327 (the first of these affects only the tests for nroot; the second and third are behaviour bugs in geometric_mean). With the lack of tests, and Python 3.6 b2 looming, I think the best thing to do might be to defer the inclusion of geometric_mean to Python 3.7.
I'll mark this as a release blocker until we decide what to do.
Unfortunately I'm in a pickle at the moment, I cannot build 3.6 on any
of the machines I have available (three), and no time to upgrade them to
something that will build 3.6. But I can provide some tests, if
somebody is willing to review and check them in to 3.6.
I was hoping that the open issues could be resolved in time for b2 but that seems unlikely at this point. So I have to agree that this feature should be deferred to 3.7. Steven, can you make the necessary reverts on the 3.6 branch?
The newly-added statistics.geometric_mean function appears to have no
tests at all
That's weird and unfortunate. I certainly wrote tests, and I have a
backup of them. I have no idea what happened.
Attached is a patch that adds the tests, but obviously I haven't been
able to run this until I resolve my gcc issues and can build 3.6 again.
(I did run this some weeks ago, and they passed *then*, but I cannot be
sure they still pass now.) If somebody would like to test this for me,
it would be appreciated.
Traceback (most recent call last):
File "/Users/inada-n/work/python/py36/Lib/test/test_statistics.py", line 1741, in test_negative_errorself.assertRaises(exc, self.func, values)
File "/Users/inada-n/work/python/py36/Lib/unittest/case.py", line 728, in assertRaisesreturn 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_meanifisinstance(g, (numbers.Real, Decimal)):
NameError: name 'g' is not defined
Traceback (most recent call last):
File "/Users/inada-n/work/python/py36/Lib/test/test_statistics.py", line 1587, in test_single_valueself.assertEqual(self.func([x]), x)
File "/Users/inada-n/work/python/py36/Lib/statistics.py", line 567, in geometric_meanifisinstance(g, (numbers.Real, Decimal)):
NameError: name 'g' is not defined
Traceback (most recent call last):
File "/Users/inada-n/work/python/py36/Lib/test/test_statistics.py", line 1762, in test_singleton_listsself.assertEqual(self.func([x]), x)
File "/Users/inada-n/work/python/py36/Lib/statistics.py", line 567, in geometric_meanifisinstance(g, (numbers.Real, Decimal)):
NameError: name 'g' is not defined
One more geometric_mean issue (the current code can enter an infinite loop for Decimal inputs): bpo-28351.
Steve, I really think we should postpone to 3.7. I'm very happy to help out with all the necessary fixes, tests and review, but I'm not going to have time for that before 3.6b2. If we defer, that takes the pressure off a bit and lets us get a good solid implementation in for 3.7.
Steve, I really think we should postpone to 3.7. [...]
If these fixes have to be in by the next beta (10th Oct), I fear that
you are right. I can build up to changeset 103135:8b74e5528f35, but not
beyond. I will be able to rectify that, but realistically it won't be
before beta2.
I expect that harmonic_mean is okay to stay in though?
I feel frustrated at how close to complete geometric_mean is,
disappointed that I can't work on it at the moment, and embarrassed that
I'm letting the team down. Sorry for the extra work I've put you
through.
Activity
mdickinson commentedon Oct 1, 2016
The newly-added statistics.geometric_mean function appears to have no tests at all, with the exception of a single doctest:
>>> geometric_mean([1.10, 0.95, 1.12]) 1.0538483123382172Steve, Ned: what do you think about taking geometric_mean out of Python 3.6, leaving us time to get it into shape for 3.7? The implementation of geometric_mean is complicated, with many edge cases. The original code was committed without review in bpo-27181, and it currently suffers from some serious bugs: see bpo-27761, bpo-28111, bpo-28327 (the first of these affects only the tests for nroot; the second and third are behaviour bugs in geometric_mean). With the lack of tests, and Python 3.6 b2 looming, I think the best thing to do might be to defer the inclusion of geometric_mean to Python 3.7.
I'll mark this as a release blocker until we decide what to do.
stevendaprano commentedon Oct 1, 2016
Unfortunately I'm in a pickle at the moment, I cannot build 3.6 on any
of the machines I have available (three), and no time to upgrade them to
something that will build 3.6. But I can provide some tests, if
somebody is willing to review and check them in to 3.6.
ned-deily commentedon Oct 2, 2016
I was hoping that the open issues could be resolved in time for b2 but that seems unlikely at this point. So I have to agree that this feature should be deferred to 3.7. Steven, can you make the necessary reverts on the 3.6 branch?
stevendaprano commentedon Oct 2, 2016
That's weird and unfortunate. I certainly wrote tests, and I have a
backup of them. I have no idea what happened.
Attached is a patch that adds the tests, but obviously I haven't been
able to run this until I resolve my gcc issues and can build 3.6 again.
(I did run this some weeks ago, and they passed *then*, but I cannot be
sure they still pass now.) If somebody would like to test this for me,
it would be appreciated.
methane commentedon Oct 3, 2016
I run attached test, and saw following errors.
On macOS 10.11 (XCode 8)
======================================================================
ERROR: test_negative_error (main.TestGeometricMean) (values=[-1])
----------------------------------------------------------------------
======================================================================
ERROR: test_single_value (main.TestGeometricMean)
----------------------------------------------------------------------
======================================================================
ERROR: test_singleton_lists (main.TestGeometricMean)
----------------------------------------------------------------------
======================================================================
FAIL: test_multiply_data_points (main.TestGeometricMean)
----------------------------------------------------------------------
methane commentedon Oct 3, 2016
Attached patch fixes first two errors.
Last one error is from test. I've commented it in review tool.
mdickinson commentedon Oct 3, 2016
One more geometric_mean issue (the current code can enter an infinite loop for Decimal inputs): bpo-28351.
Steve, I really think we should postpone to 3.7. I'm very happy to help out with all the necessary fixes, tests and review, but I'm not going to have time for that before 3.6b2. If we defer, that takes the pressure off a bit and lets us get a good solid implementation in for 3.7.
stevendaprano commentedon Oct 4, 2016
If these fixes have to be in by the next beta (10th Oct), I fear that
you are right. I can build up to changeset 103135:8b74e5528f35, but not
beyond. I will be able to rectify that, but realistically it won't be
before beta2.
I expect that harmonic_mean is okay to stay in though?
I feel frustrated at how close to complete geometric_mean is,
disappointed that I can't work on it at the moment, and embarrassed that
I'm letting the team down. Sorry for the extra work I've put you
through.
I can do the removals -- probably tonight.
methane commentedon Dec 7, 2016
3.6rc1 is released.
What is status of this issue?
methane commentedon Dec 7, 2016
It had been rolled back.
https://hg.python.org/cpython/rev/9dce0e41bedd
Can we close this issue? bpo-27181 is still open.