Issue #10650: Remove the non-standard 'watchexp' parameter from the
Decimal.quantize() method in the Python version. It had never been present in the C version.
This commit is contained in:
parent
5c2ac8c1c6
commit
b151f8f60b
|
@ -744,7 +744,7 @@ Decimal objects
|
||||||
* ``"NaN"``, indicating that the operand is a quiet NaN (Not a Number).
|
* ``"NaN"``, indicating that the operand is a quiet NaN (Not a Number).
|
||||||
* ``"sNaN"``, indicating that the operand is a signaling NaN.
|
* ``"sNaN"``, indicating that the operand is a signaling NaN.
|
||||||
|
|
||||||
.. method:: quantize(exp, rounding=None, context=None, watchexp=True)
|
.. method:: quantize(exp, rounding=None, context=None)
|
||||||
|
|
||||||
Return a value equal to the first operand after rounding and having the
|
Return a value equal to the first operand after rounding and having the
|
||||||
exponent of the second operand.
|
exponent of the second operand.
|
||||||
|
@ -767,14 +767,8 @@ Decimal objects
|
||||||
``context`` argument; if neither argument is given the rounding mode of
|
``context`` argument; if neither argument is given the rounding mode of
|
||||||
the current thread's context is used.
|
the current thread's context is used.
|
||||||
|
|
||||||
If *watchexp* is set (default), then an error is returned whenever the
|
An error is returned whenever the resulting exponent is greater than
|
||||||
resulting exponent is greater than :attr:`Emax` or less than
|
:attr:`Emax` or less than :attr:`Etiny`.
|
||||||
:attr:`Etiny`.
|
|
||||||
|
|
||||||
.. deprecated:: 3.3
|
|
||||||
*watchexp* is an implementation detail from the pure Python version
|
|
||||||
and is not present in the C version. It will be removed in version
|
|
||||||
3.4, where it defaults to ``True``.
|
|
||||||
|
|
||||||
.. method:: radix()
|
.. method:: radix()
|
||||||
|
|
||||||
|
|
|
@ -2523,7 +2523,7 @@ class Decimal(object):
|
||||||
end -= 1
|
end -= 1
|
||||||
return _dec_from_triple(dup._sign, dup._int[:end], exp)
|
return _dec_from_triple(dup._sign, dup._int[:end], exp)
|
||||||
|
|
||||||
def quantize(self, exp, rounding=None, context=None, watchexp=True):
|
def quantize(self, exp, rounding=None, context=None):
|
||||||
"""Quantize self so its exponent is the same as that of exp.
|
"""Quantize self so its exponent is the same as that of exp.
|
||||||
|
|
||||||
Similar to self._rescale(exp._exp) but with error checking.
|
Similar to self._rescale(exp._exp) but with error checking.
|
||||||
|
@ -2546,16 +2546,6 @@ class Decimal(object):
|
||||||
return context._raise_error(InvalidOperation,
|
return context._raise_error(InvalidOperation,
|
||||||
'quantize with one INF')
|
'quantize with one INF')
|
||||||
|
|
||||||
# if we're not watching exponents, do a simple rescale
|
|
||||||
if not watchexp:
|
|
||||||
ans = self._rescale(exp._exp, rounding)
|
|
||||||
# raise Inexact and Rounded where appropriate
|
|
||||||
if ans._exp > self._exp:
|
|
||||||
context._raise_error(Rounded)
|
|
||||||
if ans != self:
|
|
||||||
context._raise_error(Inexact)
|
|
||||||
return ans
|
|
||||||
|
|
||||||
# exp._exp should be between Etiny and Emax
|
# exp._exp should be between Etiny and Emax
|
||||||
if not (context.Etiny() <= exp._exp <= context.Emax):
|
if not (context.Etiny() <= exp._exp <= context.Emax):
|
||||||
return context._raise_error(InvalidOperation,
|
return context._raise_error(InvalidOperation,
|
||||||
|
|
|
@ -4448,18 +4448,6 @@ class PyCoverage(Coverage):
|
||||||
class PyFunctionality(unittest.TestCase):
|
class PyFunctionality(unittest.TestCase):
|
||||||
"""Extra functionality in decimal.py"""
|
"""Extra functionality in decimal.py"""
|
||||||
|
|
||||||
def test_py_quantize_watchexp(self):
|
|
||||||
# watchexp functionality
|
|
||||||
Decimal = P.Decimal
|
|
||||||
localcontext = P.localcontext
|
|
||||||
|
|
||||||
with localcontext() as c:
|
|
||||||
c.prec = 1
|
|
||||||
c.Emax = 1
|
|
||||||
c.Emin = -1
|
|
||||||
x = Decimal(99999).quantize(Decimal("1e3"), watchexp=False)
|
|
||||||
self.assertEqual(x, Decimal('1.00E+5'))
|
|
||||||
|
|
||||||
def test_py_alternate_formatting(self):
|
def test_py_alternate_formatting(self):
|
||||||
# triples giving a format, a Decimal, and the expected result
|
# triples giving a format, a Decimal, and the expected result
|
||||||
Decimal = P.Decimal
|
Decimal = P.Decimal
|
||||||
|
|
|
@ -60,6 +60,10 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #10650: Remove the non-standard 'watchexp' parameter from the
|
||||||
|
Decimal.quantize() method in the Python version. It had never been
|
||||||
|
present in the C version.
|
||||||
|
|
||||||
- Issue #21321: itertools.islice() now releases the reference to the source
|
- Issue #21321: itertools.islice() now releases the reference to the source
|
||||||
iterator when the slice is exhausted. Patch by Anton Afanasyev.
|
iterator when the slice is exhausted. Patch by Anton Afanasyev.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue