Skip to content

Commit 9d79e71

Browse files
[3.14] gh-150285: Fix too long docstrings in the decimal module (GH-150288) (GH-150460)
(cherry picked from commit 6bed57a)
1 parent 36137e4 commit 9d79e71

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
@@ -104,8 +104,8 @@ class DecimalException(ArithmeticError):
104104
anything, though.
105105
106106
handle -- Called when context._raise_error is called and the
107-
trap_enabler is not set. First argument is self, second is the
108-
context. More arguments can be given, those being after
107+
trap_enabler is not set. First argument is self, second is
108+
the context. More arguments can be given, those being after
109109
the explanation in _raise_error (For example,
110110
context._raise_error(NewError, '(-x)!', self._sign) would
111111
call NewError().handle(context, self._sign).)
@@ -222,11 +222,12 @@ class InvalidContext(InvalidOperation):
222222
"""Invalid context. Unknown rounding, for example.
223223
224224
This occurs and signals invalid-operation if an invalid context was
225-
detected during an operation. This can occur if contexts are not checked
226-
on creation and either the precision exceeds the capability of the
227-
underlying concrete representation or an unknown or unsupported rounding
228-
was specified. These aspects of the context need only be checked when
229-
the values are required to be used. The result is [0,qNaN].
225+
detected during an operation. This can occur if contexts are not
226+
checked on creation and either the precision exceeds the capability of
227+
the underlying concrete representation or an unknown or unsupported
228+
rounding was specified. These aspects of the context need only be
229+
checked when the values are required to be used. The result is
230+
[0,qNaN].
230231
"""
231232

232233
def handle(self, context, *args):
@@ -319,8 +320,9 @@ class FloatOperation(DecimalException, TypeError):
319320
Decimal.from_float() or context.create_decimal_from_float() do not
320321
set the flag.
321322
322-
Otherwise (the signal is trapped), only equality comparisons and explicit
323-
conversions are silent. All other mixed operations raise FloatOperation.
323+
Otherwise (the signal is trapped), only equality comparisons and
324+
explicit conversions are silent. All other mixed operations raise
325+
FloatOperation.
324326
"""
325327

326328
# List of public traps and flags
@@ -2898,8 +2900,8 @@ def compare_total(self, other, context=None):
28982900
"""Compares self to other using the abstract representations.
28992901
29002902
This is not like the standard compare, which use their numerical
2901-
value. Note that a total ordering is defined for all possible abstract
2902-
representations.
2903+
value. Note that a total ordering is defined for all possible
2904+
abstract representations.
29032905
"""
29042906
other = _convert_other(other, raiseit=True)
29052907

@@ -2970,7 +2972,8 @@ def compare_total(self, other, context=None):
29702972
def compare_total_mag(self, other, context=None):
29712973
"""Compares self to other using abstract repr., ignoring sign.
29722974
2973-
Like compare_total, but with operand's sign ignored and assumed to be 0.
2975+
Like compare_total, but with operand's sign ignored and assumed to
2976+
be 0.
29742977
"""
29752978
other = _convert_other(other, raiseit=True)
29762979

@@ -4107,9 +4110,9 @@ def create_decimal_from_float(self, f):
41074110
def abs(self, a):
41084111
"""Returns the absolute value of the operand.
41094112
4110-
If the operand is negative, the result is the same as using the minus
4111-
operation on the operand. Otherwise, the result is the same as using
4112-
the plus operation on the operand.
4113+
If the operand is negative, the result is the same as using the
4114+
minus operation on the operand. Otherwise, the result is the same
4115+
as using the plus operation on the operand.
41134116
41144117
>>> ExtendedContext.abs(Decimal('2.1'))
41154118
Decimal('2.1')
@@ -4165,16 +4168,17 @@ def canonical(self, a):
41654168
def compare(self, a, b):
41664169
"""Compares values numerically.
41674170
4168-
If the signs of the operands differ, a value representing each operand
4169-
('-1' if the operand is less than zero, '0' if the operand is zero or
4170-
negative zero, or '1' if the operand is greater than zero) is used in
4171-
place of that operand for the comparison instead of the actual
4172-
operand.
4171+
If the signs of the operands differ, a value representing each
4172+
operand ('-1' if the operand is less than zero, '0' if the operand
4173+
is zero or negative zero, or '1' if the operand is greater than
4174+
zero) is used in place of that operand for the comparison instead of
4175+
the actual operand.
41734176
4174-
The comparison is then effected by subtracting the second operand from
4175-
the first and then returning a value according to the result of the
4176-
subtraction: '-1' if the result is less than zero, '0' if the result is
4177-
zero or negative zero, or '1' if the result is greater than zero.
4177+
The comparison is then effected by subtracting the second operand
4178+
from the first and then returning a value according to the result of
4179+
the subtraction: '-1' if the result is less than zero, '0' if the
4180+
result is zero or negative zero, or '1' if the result is greater
4181+
than zero.
41784182
41794183
>>> ExtendedContext.compare(Decimal('2.1'), Decimal('3'))
41804184
Decimal('-1')
@@ -4237,8 +4241,8 @@ def compare_total(self, a, b):
42374241
"""Compares two operands using their abstract representation.
42384242
42394243
This is not like the standard compare, which use their numerical
4240-
value. Note that a total ordering is defined for all possible abstract
4241-
representations.
4244+
value. Note that a total ordering is defined for all possible
4245+
abstract representations.
42424246
42434247
>>> ExtendedContext.compare_total(Decimal('12.73'), Decimal('127.9'))
42444248
Decimal('-1')
@@ -4265,7 +4269,8 @@ def compare_total(self, a, b):
42654269
def compare_total_mag(self, a, b):
42664270
"""Compares two operands using their abstract representation ignoring sign.
42674271
4268-
Like compare_total, but with operand's sign ignored and assumed to be 0.
4272+
Like compare_total, but with operand's sign ignored and assumed to
4273+
be 0.
42694274
"""
42704275
a = _convert_other(a, raiseit=True)
42714276
return a.compare_total_mag(b)
@@ -4923,8 +4928,8 @@ def multiply(self, a, b):
49234928
49244929
If either operand is a special value then the general rules apply.
49254930
Otherwise, the operands are multiplied together
4926-
('long multiplication'), resulting in a number which may be as long as
4927-
the sum of the lengths of the two operands.
4931+
('long multiplication'), resulting in a number which may be as long
4932+
as the sum of the lengths of the two operands.
49284933
49294934
>>> ExtendedContext.multiply(Decimal('1.20'), Decimal('3'))
49304935
Decimal('3.60')
@@ -5200,19 +5205,19 @@ def quantize(self, a, b):
52005205
"""Returns a value equal to 'a' (rounded), having the exponent of 'b'.
52015206
52025207
The coefficient of the result is derived from that of the left-hand
5203-
operand. It may be rounded using the current rounding setting (if the
5204-
exponent is being increased), multiplied by a positive power of ten (if
5205-
the exponent is being decreased), or is unchanged (if the exponent is
5206-
already equal to that of the right-hand operand).
5208+
operand. It may be rounded using the current rounding setting (if
5209+
the exponent is being increased), multiplied by a positive power of
5210+
ten (if the exponent is being decreased), or is unchanged (if the
5211+
exponent is already equal to that of the right-hand operand).
52075212
52085213
Unlike other operations, if the length of the coefficient after the
52095214
quantize operation would be greater than precision then an Invalid
5210-
operation condition is raised. This guarantees that, unless there is
5211-
an error condition, the exponent of the result of a quantize is always
5212-
equal to that of the right-hand operand.
5215+
operation condition is raised. This guarantees that, unless there
5216+
is an error condition, the exponent of the result of a quantize is
5217+
always equal to that of the right-hand operand.
52135218
5214-
Also unlike other operations, quantize will never raise Underflow, even
5215-
if the result is subnormal and inexact.
5219+
Also unlike other operations, quantize will never raise Underflow,
5220+
even if the result is subnormal and inexact.
52165221
52175222
>>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.001'))
52185223
Decimal('2.170')
@@ -5266,13 +5271,13 @@ def remainder(self, a, b):
52665271
"""Returns the remainder from integer division.
52675272
52685273
The result is the residue of the dividend after the operation of
5269-
calculating integer division as described for divide-integer, rounded
5270-
to precision digits if necessary. The sign of the result, if
5271-
non-zero, is the same as that of the original dividend.
5274+
calculating integer division as described for divide-integer,
5275+
rounded to precision digits if necessary. The sign of the result,
5276+
if non-zero, is the same as that of the original dividend.
52725277
5273-
This operation will fail under the same conditions as integer division
5274-
(that is, if integer division on the same two operands would fail, the
5275-
remainder cannot be calculated).
5278+
This operation will fail under the same conditions as integer
5279+
division (that is, if integer division on the same two operands
5280+
would fail, the remainder cannot be calculated).
52765281
52775282
>>> ExtendedContext.remainder(Decimal('2.1'), Decimal('3'))
52785283
Decimal('2.1')
@@ -5306,9 +5311,9 @@ def remainder_near(self, a, b):
53065311
is chosen). If the result is equal to 0 then its sign will be the
53075312
sign of a.
53085313
5309-
This operation will fail under the same conditions as integer division
5310-
(that is, if integer division on the same two operands would fail, the
5311-
remainder cannot be calculated).
5314+
This operation will fail under the same conditions as integer
5315+
division (that is, if integer division on the same two operands
5316+
would fail, the remainder cannot be calculated).
53125317
53135318
>>> ExtendedContext.remainder_near(Decimal('2.1'), Decimal('3'))
53145319
Decimal('-0.9')
@@ -5366,8 +5371,8 @@ def rotate(self, a, b):
53665371
def same_quantum(self, a, b):
53675372
"""Returns True if the two operands have the same exponent.
53685373
5369-
The result is never affected by either the sign or the coefficient of
5370-
either operand.
5374+
The result is never affected by either the sign or the coefficient
5375+
of either operand.
53715376
53725377
>>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.001'))
53735378
False
@@ -5439,8 +5444,8 @@ def shift(self, a, b):
54395444
def sqrt(self, a):
54405445
"""Square root of a non-negative number to context precision.
54415446
5442-
If the result must be inexact, it is rounded using the round-half-even
5443-
algorithm.
5447+
If the result must be inexact, it is rounded using the
5448+
round-half-even algorithm.
54445449
54455450
>>> ExtendedContext.sqrt(Decimal('0'))
54465451
Decimal('0')

0 commit comments

Comments
 (0)