Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b151f8f

Browse files
author
Stefan Krah
committed
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.
1 parent 5c2ac8c commit b151f8f

4 files changed

Lines changed: 8 additions & 32 deletions

File tree

Doc/library/decimal.rst

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ Decimal objects
744744
* ``"NaN"``, indicating that the operand is a quiet NaN (Not a Number).
745745
* ``"sNaN"``, indicating that the operand is a signaling NaN.
746746

747-
.. method:: quantize(exp, rounding=None, context=None, watchexp=True)
747+
.. method:: quantize(exp, rounding=None, context=None)
748748

749749
Return a value equal to the first operand after rounding and having the
750750
exponent of the second operand.
@@ -767,14 +767,8 @@ Decimal objects
767767
``context`` argument; if neither argument is given the rounding mode of
768768
the current thread's context is used.
769769

770-
If *watchexp* is set (default), then an error is returned whenever the
771-
resulting exponent is greater than :attr:`Emax` or less than
772-
:attr:`Etiny`.
773-
774-
.. deprecated:: 3.3
775-
*watchexp* is an implementation detail from the pure Python version
776-
and is not present in the C version. It will be removed in version
777-
3.4, where it defaults to ``True``.
770+
An error is returned whenever the resulting exponent is greater than
771+
:attr:`Emax` or less than :attr:`Etiny`.
778772

779773
.. method:: radix()
780774

Lib/decimal.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2523,7 +2523,7 @@ def normalize(self, context=None):
25232523
end -= 1
25242524
return _dec_from_triple(dup._sign, dup._int[:end], exp)
25252525

2526-
def quantize(self, exp, rounding=None, context=None, watchexp=True):
2526+
def quantize(self, exp, rounding=None, context=None):
25272527
"""Quantize self so its exponent is the same as that of exp.
25282528
25292529
Similar to self._rescale(exp._exp) but with error checking.
@@ -2546,16 +2546,6 @@ def quantize(self, exp, rounding=None, context=None, watchexp=True):
25462546
return context._raise_error(InvalidOperation,
25472547
'quantize with one INF')
25482548

2549-
# if we're not watching exponents, do a simple rescale
2550-
if not watchexp:
2551-
ans = self._rescale(exp._exp, rounding)
2552-
# raise Inexact and Rounded where appropriate
2553-
if ans._exp > self._exp:
2554-
context._raise_error(Rounded)
2555-
if ans != self:
2556-
context._raise_error(Inexact)
2557-
return ans
2558-
25592549
# exp._exp should be between Etiny and Emax
25602550
if not (context.Etiny() <= exp._exp <= context.Emax):
25612551
return context._raise_error(InvalidOperation,

Lib/test/test_decimal.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4448,18 +4448,6 @@ class PyCoverage(Coverage):
44484448
class PyFunctionality(unittest.TestCase):
44494449
"""Extra functionality in decimal.py"""
44504450

4451-
def test_py_quantize_watchexp(self):
4452-
# watchexp functionality
4453-
Decimal = P.Decimal
4454-
localcontext = P.localcontext
4455-
4456-
with localcontext() as c:
4457-
c.prec = 1
4458-
c.Emax = 1
4459-
c.Emin = -1
4460-
x = Decimal(99999).quantize(Decimal("1e3"), watchexp=False)
4461-
self.assertEqual(x, Decimal('1.00E+5'))
4462-
44634451
def test_py_alternate_formatting(self):
44644452
# triples giving a format, a Decimal, and the expected result
44654453
Decimal = P.Decimal

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ Core and Builtins
6060
Library
6161
-------
6262

63+
- Issue #10650: Remove the non-standard 'watchexp' parameter from the
64+
Decimal.quantize() method in the Python version. It had never been
65+
present in the C version.
66+
6367
- Issue #21321: itertools.islice() now releases the reference to the source
6468
iterator when the slice is exhausted. Patch by Anton Afanasyev.
6569

0 commit comments

Comments
 (0)