Skip to content

Commit 808deca

Browse files
gh-150285: Fix too long docstrings in the decimal module
1 parent a7d5a6c commit 808deca

3 files changed

Lines changed: 213 additions & 191 deletions

File tree

Lib/_pydecimal.py

Lines changed: 56 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ class DecimalException(ArithmeticError):
107107
anything, though.
108108
109109
handle -- Called when context._raise_error is called and the
110-
trap_enabler is not set. First argument is self, second is the
111-
context. More arguments can be given, those being after
110+
trap_enabler is not set. First argument is self, second is
111+
the context. More arguments can be given, those being after
112112
the explanation in _raise_error (For example,
113113
context._raise_error(NewError, '(-x)!', self._sign) would
114114
call NewError().handle(context, self._sign).)
@@ -225,11 +225,12 @@ class InvalidContext(InvalidOperation):
225225
"""Invalid context. Unknown rounding, for example.
226226
227227
This occurs and signals invalid-operation if an invalid context was
228-
detected during an operation. This can occur if contexts are not checked
229-
on creation and either the precision exceeds the capability of the
230-
underlying concrete representation or an unknown or unsupported rounding
231-
was specified. These aspects of the context need only be checked when
232-
the values are required to be used. The result is [0,qNaN].
228+
detected during an operation. This can occur if contexts are not
229+
checked on creation and either the precision exceeds the capability of
230+
the underlying concrete representation or an unknown or unsupported
231+
rounding was specified. These aspects of the context need only be
232+
checked when the values are required to be used. The result is
233+
[0,qNaN].
233234
"""
234235

235236
def handle(self, context, *args):
@@ -322,8 +323,9 @@ class FloatOperation(DecimalException, TypeError):
322323
Decimal.from_float() or context.create_decimal_from_float() do not
323324
set the flag.
324325
325-
Otherwise (the signal is trapped), only equality comparisons and explicit
326-
conversions are silent. All other mixed operations raise FloatOperation.
326+
Otherwise (the signal is trapped), only equality comparisons and
327+
explicit conversions are silent. All other mixed operations raise
328+
FloatOperation.
327329
"""
328330

329331
# List of public traps and flags
@@ -2901,8 +2903,8 @@ def compare_total(self, other, context=None):
29012903
"""Compares self to other using the abstract representations.
29022904
29032905
This is not like the standard compare, which use their numerical
2904-
value. Note that a total ordering is defined for all possible abstract
2905-
representations.
2906+
value. Note that a total ordering is defined for all possible
2907+
abstract representations.
29062908
"""
29072909
other = _convert_other(other, raiseit=True)
29082910

@@ -2973,7 +2975,8 @@ def compare_total(self, other, context=None):
29732975
def compare_total_mag(self, other, context=None):
29742976
"""Compares self to other using abstract repr., ignoring sign.
29752977
2976-
Like compare_total, but with operand's sign ignored and assumed to be 0.
2978+
Like compare_total, but with operand's sign ignored and assumed to
2979+
be 0.
29772980
"""
29782981
other = _convert_other(other, raiseit=True)
29792982

@@ -4110,9 +4113,9 @@ def create_decimal_from_float(self, f):
41104113
def abs(self, a):
41114114
"""Returns the absolute value of the operand.
41124115
4113-
If the operand is negative, the result is the same as using the minus
4114-
operation on the operand. Otherwise, the result is the same as using
4115-
the plus operation on the operand.
4116+
If the operand is negative, the result is the same as using the
4117+
minus operation on the operand. Otherwise, the result is the same
4118+
as using the plus operation on the operand.
41164119
41174120
>>> ExtendedContext.abs(Decimal('2.1'))
41184121
Decimal('2.1')
@@ -4168,16 +4171,17 @@ def canonical(self, a):
41684171
def compare(self, a, b):
41694172
"""Compares values numerically.
41704173
4171-
If the signs of the operands differ, a value representing each operand
4172-
('-1' if the operand is less than zero, '0' if the operand is zero or
4173-
negative zero, or '1' if the operand is greater than zero) is used in
4174-
place of that operand for the comparison instead of the actual
4175-
operand.
4174+
If the signs of the operands differ, a value representing each
4175+
operand ('-1' if the operand is less than zero, '0' if the operand
4176+
is zero or negative zero, or '1' if the operand is greater than
4177+
zero) is used in place of that operand for the comparison instead of
4178+
the actual operand.
41764179
4177-
The comparison is then effected by subtracting the second operand from
4178-
the first and then returning a value according to the result of the
4179-
subtraction: '-1' if the result is less than zero, '0' if the result is
4180-
zero or negative zero, or '1' if the result is greater than zero.
4180+
The comparison is then effected by subtracting the second operand
4181+
from the first and then returning a value according to the result of
4182+
the subtraction: '-1' if the result is less than zero, '0' if the
4183+
result is zero or negative zero, or '1' if the result is greater
4184+
than zero.
41814185
41824186
>>> ExtendedContext.compare(Decimal('2.1'), Decimal('3'))
41834187
Decimal('-1')
@@ -4240,8 +4244,8 @@ def compare_total(self, a, b):
42404244
"""Compares two operands using their abstract representation.
42414245
42424246
This is not like the standard compare, which use their numerical
4243-
value. Note that a total ordering is defined for all possible abstract
4244-
representations.
4247+
value. Note that a total ordering is defined for all possible
4248+
abstract representations.
42454249
42464250
>>> ExtendedContext.compare_total(Decimal('12.73'), Decimal('127.9'))
42474251
Decimal('-1')
@@ -4268,7 +4272,8 @@ def compare_total(self, a, b):
42684272
def compare_total_mag(self, a, b):
42694273
"""Compares two operands using their abstract representation ignoring sign.
42704274
4271-
Like compare_total, but with operand's sign ignored and assumed to be 0.
4275+
Like compare_total, but with operand's sign ignored and assumed to
4276+
be 0.
42724277
"""
42734278
a = _convert_other(a, raiseit=True)
42744279
return a.compare_total_mag(b)
@@ -4926,8 +4931,8 @@ def multiply(self, a, b):
49264931
49274932
If either operand is a special value then the general rules apply.
49284933
Otherwise, the operands are multiplied together
4929-
('long multiplication'), resulting in a number which may be as long as
4930-
the sum of the lengths of the two operands.
4934+
('long multiplication'), resulting in a number which may be as long
4935+
as the sum of the lengths of the two operands.
49314936
49324937
>>> ExtendedContext.multiply(Decimal('1.20'), Decimal('3'))
49334938
Decimal('3.60')
@@ -5203,19 +5208,19 @@ def quantize(self, a, b):
52035208
"""Returns a value equal to 'a' (rounded), having the exponent of 'b'.
52045209
52055210
The coefficient of the result is derived from that of the left-hand
5206-
operand. It may be rounded using the current rounding setting (if the
5207-
exponent is being increased), multiplied by a positive power of ten (if
5208-
the exponent is being decreased), or is unchanged (if the exponent is
5209-
already equal to that of the right-hand operand).
5211+
operand. It may be rounded using the current rounding setting (if
5212+
the exponent is being increased), multiplied by a positive power of
5213+
ten (if the exponent is being decreased), or is unchanged (if the
5214+
exponent is already equal to that of the right-hand operand).
52105215
52115216
Unlike other operations, if the length of the coefficient after the
52125217
quantize operation would be greater than precision then an Invalid
5213-
operation condition is raised. This guarantees that, unless there is
5214-
an error condition, the exponent of the result of a quantize is always
5215-
equal to that of the right-hand operand.
5218+
operation condition is raised. This guarantees that, unless there
5219+
is an error condition, the exponent of the result of a quantize is
5220+
always equal to that of the right-hand operand.
52165221
5217-
Also unlike other operations, quantize will never raise Underflow, even
5218-
if the result is subnormal and inexact.
5222+
Also unlike other operations, quantize will never raise Underflow,
5223+
even if the result is subnormal and inexact.
52195224
52205225
>>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.001'))
52215226
Decimal('2.170')
@@ -5269,13 +5274,13 @@ def remainder(self, a, b):
52695274
"""Returns the remainder from integer division.
52705275
52715276
The result is the residue of the dividend after the operation of
5272-
calculating integer division as described for divide-integer, rounded
5273-
to precision digits if necessary. The sign of the result, if
5274-
non-zero, is the same as that of the original dividend.
5277+
calculating integer division as described for divide-integer,
5278+
rounded to precision digits if necessary. The sign of the result,
5279+
if non-zero, is the same as that of the original dividend.
52755280
5276-
This operation will fail under the same conditions as integer division
5277-
(that is, if integer division on the same two operands would fail, the
5278-
remainder cannot be calculated).
5281+
This operation will fail under the same conditions as integer
5282+
division (that is, if integer division on the same two operands
5283+
would fail, the remainder cannot be calculated).
52795284
52805285
>>> ExtendedContext.remainder(Decimal('2.1'), Decimal('3'))
52815286
Decimal('2.1')
@@ -5309,9 +5314,9 @@ def remainder_near(self, a, b):
53095314
is chosen). If the result is equal to 0 then its sign will be the
53105315
sign of a.
53115316
5312-
This operation will fail under the same conditions as integer division
5313-
(that is, if integer division on the same two operands would fail, the
5314-
remainder cannot be calculated).
5317+
This operation will fail under the same conditions as integer
5318+
division (that is, if integer division on the same two operands
5319+
would fail, the remainder cannot be calculated).
53155320
53165321
>>> ExtendedContext.remainder_near(Decimal('2.1'), Decimal('3'))
53175322
Decimal('-0.9')
@@ -5369,8 +5374,8 @@ def rotate(self, a, b):
53695374
def same_quantum(self, a, b):
53705375
"""Returns True if the two operands have the same exponent.
53715376
5372-
The result is never affected by either the sign or the coefficient of
5373-
either operand.
5377+
The result is never affected by either the sign or the coefficient
5378+
of either operand.
53745379
53755380
>>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.001'))
53765381
False
@@ -5442,8 +5447,8 @@ def shift(self, a, b):
54425447
def sqrt(self, a):
54435448
"""Square root of a non-negative number to context precision.
54445449
5445-
If the result must be inexact, it is rounded using the round-half-even
5446-
algorithm.
5450+
If the result must be inexact, it is rounded using the
5451+
round-half-even algorithm.
54475452
54485453
>>> ExtendedContext.sqrt(Decimal('0'))
54495454
Decimal('0')

0 commit comments

Comments
 (0)