Message210427
As I understand, _decimal_to_ratio() should always produce an
integer ratio. But it does not for positive exponents:
>>> import statistics
>>> statistics.mean([Decimal("100"), Decimal("200")])
Decimal('150')
>>> statistics.mean([Decimal("1e2"), Decimal("2e2")])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/statistics.py", line 308, in mean
return _sum(data)/n
File "/usr/local/lib/python3.4/statistics.py", line 166, in _sum
total += Fraction(n, d)
File "/usr/local/lib/python3.4/fractions.py", line 163, in __new__
raise TypeError("both arguments should be "
TypeError: both arguments should be Rational instances
>>>
>>> statistics._decimal_to_ratio(Decimal("1e2"))
(1, 0.01)
>>> 1e2.as_integer_ratio()
(100, 1) |
|
Date |
User |
Action |
Args |
2014-02-06 23:42:19 | skrah | set | recipients:
+ skrah, steven.daprano |
2014-02-06 23:42:19 | skrah | set | messageid: <1391730139.77.0.406178455931.issue20536@psf.upfronthosting.co.za> |
2014-02-06 23:42:19 | skrah | link | issue20536 messages |
2014-02-06 23:42:19 | skrah | create | |
|