Skip to content

Commit 9463c9d

Browse files
[3.13] gh-150285: Fix too long docstrings in the decimal module (GH-150288) (GH-150460) (GH-150465)
(cherry picked from commit 9d79e71) (cherry picked from commit 6bed57a) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent 7d265b6 commit 9463c9d

1 file changed

Lines changed: 56 additions & 51 deletions

File tree

Lib/_pydecimal.py

Lines changed: 56 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ class DecimalException(ArithmeticError):
102102
anything, though.
103103
104104
handle -- Called when context._raise_error is called and the
105-
trap_enabler is not set. First argument is self, second is the
106-
context. More arguments can be given, those being after
105+
trap_enabler is not set. First argument is self, second is
106+
the context. More arguments can be given, those being after
107107
the explanation in _raise_error (For example,
108108
context._raise_error(NewError, '(-x)!', self._sign) would
109109
call NewError().handle(context, self._sign).)
@@ -220,11 +220,12 @@ class InvalidContext(InvalidOperation):
220220
"""Invalid context. Unknown rounding, for example.
221221
222222
This occurs and signals invalid-operation if an invalid context was
223-
detected during an operation. This can occur if contexts are not checked
224-
on creation and either the precision exceeds the capability of the
225-
underlying concrete representation or an unknown or unsupported rounding
226-
was specified. These aspects of the context need only be checked when
227-
the values are required to be used. The result is [0,qNaN].
223+
detected during an operation. This can occur if contexts are not
224+
checked on creation and either the precision exceeds the capability of
225+
the underlying concrete representation or an unknown or unsupported
226+
rounding was specified. These aspects of the context need only be
227+
checked when the values are required to be used. The result is
228+
[0,qNaN].
228229
"""
229230

230231
def handle(self, context, *args):
@@ -317,8 +318,9 @@ class FloatOperation(DecimalException, TypeError):
317318
Decimal.from_float() or context.create_decimal_from_float() do not
318319
set the flag.
319320
320-
Otherwise (the signal is trapped), only equality comparisons and explicit
321-
conversions are silent. All other mixed operations raise FloatOperation.
321+
Otherwise (the signal is trapped), only equality comparisons and
322+
explicit conversions are silent. All other mixed operations raise
323+
FloatOperation.
322324
"""
323325

324326
# List of public traps and flags
@@ -2860,8 +2862,8 @@ def compare_total(self, other, context=None):
28602862
"""Compares self to other using the abstract representations.
28612863
28622864
This is not like the standard compare, which use their numerical
2863-
value. Note that a total ordering is defined for all possible abstract
2864-
representations.
2865+
value. Note that a total ordering is defined for all possible
2866+
abstract representations.
28652867
"""
28662868
other = _convert_other(other, raiseit=True)
28672869

@@ -2932,7 +2934,8 @@ def compare_total(self, other, context=None):
29322934
def compare_total_mag(self, other, context=None):
29332935
"""Compares self to other using abstract repr., ignoring sign.
29342936
2935-
Like compare_total, but with operand's sign ignored and assumed to be 0.
2937+
Like compare_total, but with operand's sign ignored and assumed to
2938+
be 0.
29362939
"""
29372940
other = _convert_other(other, raiseit=True)
29382941

@@ -4069,9 +4072,9 @@ def create_decimal_from_float(self, f):
40694072
def abs(self, a):
40704073
"""Returns the absolute value of the operand.
40714074
4072-
If the operand is negative, the result is the same as using the minus
4073-
operation on the operand. Otherwise, the result is the same as using
4074-
the plus operation on the operand.
4075+
If the operand is negative, the result is the same as using the
4076+
minus operation on the operand. Otherwise, the result is the same
4077+
as using the plus operation on the operand.
40754078
40764079
>>> ExtendedContext.abs(Decimal('2.1'))
40774080
Decimal('2.1')
@@ -4127,16 +4130,17 @@ def canonical(self, a):
41274130
def compare(self, a, b):
41284131
"""Compares values numerically.
41294132
4130-
If the signs of the operands differ, a value representing each operand
4131-
('-1' if the operand is less than zero, '0' if the operand is zero or
4132-
negative zero, or '1' if the operand is greater than zero) is used in
4133-
place of that operand for the comparison instead of the actual
4134-
operand.
4133+
If the signs of the operands differ, a value representing each
4134+
operand ('-1' if the operand is less than zero, '0' if the operand
4135+
is zero or negative zero, or '1' if the operand is greater than
4136+
zero) is used in place of that operand for the comparison instead of
4137+
the actual operand.
41354138
4136-
The comparison is then effected by subtracting the second operand from
4137-
the first and then returning a value according to the result of the
4138-
subtraction: '-1' if the result is less than zero, '0' if the result is
4139-
zero or negative zero, or '1' if the result is greater than zero.
4139+
The comparison is then effected by subtracting the second operand
4140+
from the first and then returning a value according to the result of
4141+
the subtraction: '-1' if the result is less than zero, '0' if the
4142+
result is zero or negative zero, or '1' if the result is greater
4143+
than zero.
41404144
41414145
>>> ExtendedContext.compare(Decimal('2.1'), Decimal('3'))
41424146
Decimal('-1')
@@ -4199,8 +4203,8 @@ def compare_total(self, a, b):
41994203
"""Compares two operands using their abstract representation.
42004204
42014205
This is not like the standard compare, which use their numerical
4202-
value. Note that a total ordering is defined for all possible abstract
4203-
representations.
4206+
value. Note that a total ordering is defined for all possible
4207+
abstract representations.
42044208
42054209
>>> ExtendedContext.compare_total(Decimal('12.73'), Decimal('127.9'))
42064210
Decimal('-1')
@@ -4227,7 +4231,8 @@ def compare_total(self, a, b):
42274231
def compare_total_mag(self, a, b):
42284232
"""Compares two operands using their abstract representation ignoring sign.
42294233
4230-
Like compare_total, but with operand's sign ignored and assumed to be 0.
4234+
Like compare_total, but with operand's sign ignored and assumed to
4235+
be 0.
42314236
"""
42324237
a = _convert_other(a, raiseit=True)
42334238
return a.compare_total_mag(b)
@@ -4885,8 +4890,8 @@ def multiply(self, a, b):
48854890
48864891
If either operand is a special value then the general rules apply.
48874892
Otherwise, the operands are multiplied together
4888-
('long multiplication'), resulting in a number which may be as long as
4889-
the sum of the lengths of the two operands.
4893+
('long multiplication'), resulting in a number which may be as long
4894+
as the sum of the lengths of the two operands.
48904895
48914896
>>> ExtendedContext.multiply(Decimal('1.20'), Decimal('3'))
48924897
Decimal('3.60')
@@ -5162,19 +5167,19 @@ def quantize(self, a, b):
51625167
"""Returns a value equal to 'a' (rounded), having the exponent of 'b'.
51635168
51645169
The coefficient of the result is derived from that of the left-hand
5165-
operand. It may be rounded using the current rounding setting (if the
5166-
exponent is being increased), multiplied by a positive power of ten (if
5167-
the exponent is being decreased), or is unchanged (if the exponent is
5168-
already equal to that of the right-hand operand).
5170+
operand. It may be rounded using the current rounding setting (if
5171+
the exponent is being increased), multiplied by a positive power of
5172+
ten (if the exponent is being decreased), or is unchanged (if the
5173+
exponent is already equal to that of the right-hand operand).
51695174
51705175
Unlike other operations, if the length of the coefficient after the
51715176
quantize operation would be greater than precision then an Invalid
5172-
operation condition is raised. This guarantees that, unless there is
5173-
an error condition, the exponent of the result of a quantize is always
5174-
equal to that of the right-hand operand.
5177+
operation condition is raised. This guarantees that, unless there
5178+
is an error condition, the exponent of the result of a quantize is
5179+
always equal to that of the right-hand operand.
51755180
5176-
Also unlike other operations, quantize will never raise Underflow, even
5177-
if the result is subnormal and inexact.
5181+
Also unlike other operations, quantize will never raise Underflow,
5182+
even if the result is subnormal and inexact.
51785183
51795184
>>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.001'))
51805185
Decimal('2.170')
@@ -5228,13 +5233,13 @@ def remainder(self, a, b):
52285233
"""Returns the remainder from integer division.
52295234
52305235
The result is the residue of the dividend after the operation of
5231-
calculating integer division as described for divide-integer, rounded
5232-
to precision digits if necessary. The sign of the result, if
5233-
non-zero, is the same as that of the original dividend.
5236+
calculating integer division as described for divide-integer,
5237+
rounded to precision digits if necessary. The sign of the result,
5238+
if non-zero, is the same as that of the original dividend.
52345239
5235-
This operation will fail under the same conditions as integer division
5236-
(that is, if integer division on the same two operands would fail, the
5237-
remainder cannot be calculated).
5240+
This operation will fail under the same conditions as integer
5241+
division (that is, if integer division on the same two operands
5242+
would fail, the remainder cannot be calculated).
52385243
52395244
>>> ExtendedContext.remainder(Decimal('2.1'), Decimal('3'))
52405245
Decimal('2.1')
@@ -5268,9 +5273,9 @@ def remainder_near(self, a, b):
52685273
is chosen). If the result is equal to 0 then its sign will be the
52695274
sign of a.
52705275
5271-
This operation will fail under the same conditions as integer division
5272-
(that is, if integer division on the same two operands would fail, the
5273-
remainder cannot be calculated).
5276+
This operation will fail under the same conditions as integer
5277+
division (that is, if integer division on the same two operands
5278+
would fail, the remainder cannot be calculated).
52745279
52755280
>>> ExtendedContext.remainder_near(Decimal('2.1'), Decimal('3'))
52765281
Decimal('-0.9')
@@ -5328,8 +5333,8 @@ def rotate(self, a, b):
53285333
def same_quantum(self, a, b):
53295334
"""Returns True if the two operands have the same exponent.
53305335
5331-
The result is never affected by either the sign or the coefficient of
5332-
either operand.
5336+
The result is never affected by either the sign or the coefficient
5337+
of either operand.
53335338
53345339
>>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.001'))
53355340
False
@@ -5401,8 +5406,8 @@ def shift(self, a, b):
54015406
def sqrt(self, a):
54025407
"""Square root of a non-negative number to context precision.
54035408
5404-
If the result must be inexact, it is rounded using the round-half-even
5405-
algorithm.
5409+
If the result must be inexact, it is rounded using the
5410+
round-half-even algorithm.
54065411
54075412
>>> ExtendedContext.sqrt(Decimal('0'))
54085413
Decimal('0')

0 commit comments

Comments
 (0)