New submission from Stefan Krah: 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) ---------- components: Library (Lib) messages: 210427 nosy: skrah, stevenjd priority: high severity: normal stage: needs patch status: open title: statistics._decimal_to_ratio() produces non-integer ratio type: behavior versions: Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20536> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com