Commit 5de1f824 authored by Stefan Krah's avatar Stefan Krah

Issue #21407: _decimal now supports function signatures.

parent b9e71d4a
...@@ -39,6 +39,7 @@ from test.support import (check_warnings, import_fresh_module, TestFailed, ...@@ -39,6 +39,7 @@ from test.support import (check_warnings, import_fresh_module, TestFailed,
import random import random
import time import time
import warnings import warnings
import inspect
try: try:
import threading import threading
except ImportError: except ImportError:
...@@ -5390,6 +5391,142 @@ class CWhitebox(unittest.TestCase): ...@@ -5390,6 +5391,142 @@ class CWhitebox(unittest.TestCase):
y = Decimal(10**(9*25)).__sizeof__() y = Decimal(10**(9*25)).__sizeof__()
self.assertEqual(y, x+4) self.assertEqual(y, x+4)
unittest.skipUnless(C, "test requires C version")
class SignatureTest(unittest.TestCase):
"""Function signatures"""
def test_inspect_module(self):
for attr in dir(P):
if attr.startswith('_'):
continue
p_func = getattr(P, attr)
c_func = getattr(C, attr)
if (attr == 'Decimal' or attr == 'Context' or
inspect.isfunction(p_func)):
p_sig = inspect.signature(p_func)
c_sig = inspect.signature(c_func)
# parameter names:
c_names = list(c_sig.parameters.keys())
p_names = [x for x in p_sig.parameters.keys() if not
x.startswith('_')]
self.assertEqual(c_names, p_names,
msg="parameter name mismatch in %s" % p_func)
c_kind = [x.kind for x in c_sig.parameters.values()]
p_kind = [x[1].kind for x in p_sig.parameters.items() if not
x[0].startswith('_')]
# parameters:
if attr != 'setcontext':
self.assertEqual(c_kind, p_kind,
msg="parameter kind mismatch in %s" % p_func)
def test_inspect_types(self):
POS = inspect._ParameterKind.POSITIONAL_ONLY
POS_KWD = inspect._ParameterKind.POSITIONAL_OR_KEYWORD
# Type heuristic (type annotations would help!):
pdict = {C: {'other': C.Decimal(1),
'third': C.Decimal(1),
'x': C.Decimal(1),
'y': C.Decimal(1),
'z': C.Decimal(1),
'a': C.Decimal(1),
'b': C.Decimal(1),
'c': C.Decimal(1),
'exp': C.Decimal(1),
'modulo': C.Decimal(1),
'num': "1",
'f': 1.0,
'rounding': C.ROUND_HALF_UP,
'context': C.getcontext()},
P: {'other': P.Decimal(1),
'third': P.Decimal(1),
'a': P.Decimal(1),
'b': P.Decimal(1),
'c': P.Decimal(1),
'exp': P.Decimal(1),
'modulo': P.Decimal(1),
'num': "1",
'f': 1.0,
'rounding': P.ROUND_HALF_UP,
'context': P.getcontext()}}
def mkargs(module, sig):
args = []
kwargs = {}
for name, param in sig.parameters.items():
if name == 'self': continue
if param.kind == POS:
args.append(pdict[module][name])
elif param.kind == POS_KWD:
kwargs[name] = pdict[module][name]
else:
raise TestFailed("unexpected parameter kind")
return args, kwargs
def tr(s):
"""The C Context docstrings use 'x' in order to prevent confusion
with the article 'a' in the descriptions."""
if s == 'x': return 'a'
if s == 'y': return 'b'
if s == 'z': return 'c'
return s
def doit(ty):
p_type = getattr(P, ty)
c_type = getattr(C, ty)
for attr in dir(p_type):
if attr.startswith('_'):
continue
p_func = getattr(p_type, attr)
c_func = getattr(c_type, attr)
if inspect.isfunction(p_func):
p_sig = inspect.signature(p_func)
c_sig = inspect.signature(c_func)
# parameter names:
p_names = list(p_sig.parameters.keys())
c_names = [tr(x) for x in c_sig.parameters.keys()]
self.assertEqual(c_names, p_names,
msg="parameter name mismatch in %s" % p_func)
p_kind = [x.kind for x in p_sig.parameters.values()]
c_kind = [x.kind for x in c_sig.parameters.values()]
# 'self' parameter:
self.assertIs(p_kind[0], POS_KWD)
self.assertIs(c_kind[0], POS)
# remaining parameters:
if ty == 'Decimal':
self.assertEqual(c_kind[1:], p_kind[1:],
msg="parameter kind mismatch in %s" % p_func)
else: # Context methods are positional only in the C version.
self.assertEqual(len(c_kind), len(p_kind),
msg="parameter kind mismatch in %s" % p_func)
# Run the function:
args, kwds = mkargs(C, c_sig)
try:
getattr(c_type(9), attr)(*args, **kwds)
except Exception as err:
raise TestFailed("invalid signature for %s: %s %s" % (c_func, args, kwds))
args, kwds = mkargs(P, p_sig)
try:
getattr(p_type(9), attr)(*args, **kwds)
except Exception as err:
raise TestFailed("invalid signature for %s: %s %s" % (p_func, args, kwds))
doit('Decimal')
doit('Context')
all_tests = [ all_tests = [
CExplicitConstructionTest, PyExplicitConstructionTest, CExplicitConstructionTest, PyExplicitConstructionTest,
CImplicitConstructionTest, PyImplicitConstructionTest, CImplicitConstructionTest, PyImplicitConstructionTest,
...@@ -5415,6 +5552,7 @@ if not C: ...@@ -5415,6 +5552,7 @@ if not C:
all_tests = all_tests[1::2] all_tests = all_tests[1::2]
else: else:
all_tests.insert(0, CheckAttributes) all_tests.insert(0, CheckAttributes)
all_tests.insert(1, SignatureTest)
def test_main(arith=False, verbose=None, todo_tests=None, debug=None): def test_main(arith=False, verbose=None, todo_tests=None, debug=None):
......
...@@ -310,6 +310,8 @@ Library ...@@ -310,6 +310,8 @@ Library
Extension Modules Extension Modules
----------------- -----------------
- Issue #21407: _decimal: The module now supports function signatures.
- Issue #21276: posixmodule: Don't define USE_XATTRS on KFreeBSD and the Hurd. - Issue #21276: posixmodule: Don't define USE_XATTRS on KFreeBSD and the Hurd.
IDLE IDLE
......
...@@ -19,26 +19,30 @@ ...@@ -19,26 +19,30 @@
PyDoc_STRVAR(doc__decimal, PyDoc_STRVAR(doc__decimal,
"C decimal arithmetic module"); "C decimal arithmetic module");
PyDoc_STRVAR(doc_getcontext,"\n\ PyDoc_STRVAR(doc_getcontext,
getcontext() - Get the current default context.\n\ "getcontext($module, /)\n--\n\n\
Get the current default context.\n\
\n"); \n");
PyDoc_STRVAR(doc_setcontext,"\n\ PyDoc_STRVAR(doc_setcontext,
setcontext(c) - Set a new default context.\n\ "setcontext($module, context, /)\n--\n\n\
Set a new default context.\n\
\n"); \n");
PyDoc_STRVAR(doc_localcontext,"\n\ PyDoc_STRVAR(doc_localcontext,
localcontext(ctx=None) - Return a context manager that will set the default\n\ "localcontext($module, /, ctx=None)\n--\n\n\
context to a copy of ctx on entry to the with-statement and restore the\n\ Return a context manager that will set the default context to a copy of ctx\n\
previous default context when exiting the with-statement. If no context is\n\ on entry to the with-statement and restore the previous default context when\n\
specified, a copy of the current default context is used.\n\ exiting the with-statement. If no context is specified, a copy of the current\n\
default context is used.\n\
\n"); \n");
#ifdef EXTRA_FUNCTIONALITY #ifdef EXTRA_FUNCTIONALITY
PyDoc_STRVAR(doc_ieee_context,"\n\ PyDoc_STRVAR(doc_ieee_context,
IEEEContext(bits) - Return a context object initialized to the proper values for\n\ "IEEEContext($module, bits, /)\n--\n\n\
one of the IEEE interchange formats. The argument must be a multiple of 32 and\n\ Return a context object initialized to the proper values for one of the\n\
less than IEEE_CONTEXT_MAX_BITS. For the most common values, the constants\n\ IEEE interchange formats. The argument must be a multiple of 32 and less\n\
than IEEE_CONTEXT_MAX_BITS. For the most common values, the constants\n\
DECIMAL32, DECIMAL64 and DECIMAL128 are provided.\n\ DECIMAL32, DECIMAL64 and DECIMAL128 are provided.\n\
\n"); \n");
#endif #endif
...@@ -48,32 +52,34 @@ DECIMAL32, DECIMAL64 and DECIMAL128 are provided.\n\ ...@@ -48,32 +52,34 @@ DECIMAL32, DECIMAL64 and DECIMAL128 are provided.\n\
/* Decimal Object and Methods */ /* Decimal Object and Methods */
/******************************************************************************/ /******************************************************************************/
PyDoc_STRVAR(doc_decimal,"\n\ PyDoc_STRVAR(doc_decimal,
Decimal(value=\"0\", context=None): Construct a new Decimal object.\n\ "Decimal(value=\"0\", context=None)\n--\n\n\
value can be an integer, string, tuple, or another Decimal object.\n\ Construct a new Decimal object. 'value' can be an integer, string, tuple,\n\
If no value is given, return Decimal('0'). The context does not affect\n\ or another Decimal object. If no value is given, return Decimal('0'). The\n\
the conversion and is only passed to determine if the InvalidOperation\n\ context does not affect the conversion and is only passed to determine if\n\
trap is active.\n\ the InvalidOperation trap is active.\n\
\n"); \n");
PyDoc_STRVAR(doc_adjusted,"\n\ PyDoc_STRVAR(doc_adjusted,
adjusted() - Return the adjusted exponent of the number.\n\ "adjusted($self, /)\n--\n\n\
\n\ Return the adjusted exponent of the number. Defined as exp + digits - 1.\n\
Defined as exp + digits - 1.\n\
\n"); \n");
PyDoc_STRVAR(doc_as_tuple,"\n\ PyDoc_STRVAR(doc_as_tuple,
as_tuple() - Return a tuple representation of the number.\n\ "as_tuple($self, /)\n--\n\n\
Return a tuple representation of the number.\n\
\n"); \n");
PyDoc_STRVAR(doc_canonical,"\n\ PyDoc_STRVAR(doc_canonical,
canonical() - Return the canonical encoding of the argument. Currently,\n\ "canonical($self, /)\n--\n\n\
the encoding of a Decimal instance is always canonical, so this operation\n\ Return the canonical encoding of the argument. Currently, the encoding\n\
returns its argument unchanged.\n\ of a Decimal instance is always canonical, so this operation returns its\n\
argument unchanged.\n\
\n"); \n");
PyDoc_STRVAR(doc_compare,"\n\ PyDoc_STRVAR(doc_compare,
compare(other, context=None) - Compare self to other. Return a decimal value:\n\ "compare($self, /, other, context=None)\n--\n\n\
Compare self to other. Return a decimal value:\n\
\n\ \n\
a or b is a NaN ==> Decimal('NaN')\n\ a or b is a NaN ==> Decimal('NaN')\n\
a < b ==> Decimal('-1')\n\ a < b ==> Decimal('-1')\n\
...@@ -81,17 +87,18 @@ compare(other, context=None) - Compare self to other. Return a decimal value:\n\ ...@@ -81,17 +87,18 @@ compare(other, context=None) - Compare self to other. Return a decimal value:\n\
a > b ==> Decimal('1')\n\ a > b ==> Decimal('1')\n\
\n"); \n");
PyDoc_STRVAR(doc_compare_signal,"\n\ PyDoc_STRVAR(doc_compare_signal,
compare_signal(other, context=None) - Identical to compare, except that\n\ "compare_signal($self, /, other, context=None)\n--\n\n\
all NaNs signal.\n\ Identical to compare, except that all NaNs signal.\n\
\n"); \n");
PyDoc_STRVAR(doc_compare_total,"\n\ PyDoc_STRVAR(doc_compare_total,
compare_total(other, context=None) - Compare two operands using their\n\ "compare_total($self, /, other, context=None)\n--\n\n\
abstract representation rather than their numerical value. Similar to the\n\ Compare two operands using their abstract representation rather than\n\
compare() method, but the result gives a total ordering on Decimal instances.\n\ their numerical value. Similar to the compare() method, but the result\n\
Two Decimal instances with the same numeric value but different representations\n\ gives a total ordering on Decimal instances. Two Decimal instances with\n\
compare unequal in this ordering:\n\ the same numeric value but different representations compare unequal\n\
in this ordering:\n\
\n\ \n\
>>> Decimal('12.0').compare_total(Decimal('12'))\n\ >>> Decimal('12.0').compare_total(Decimal('12'))\n\
Decimal('-1')\n\ Decimal('-1')\n\
...@@ -107,36 +114,39 @@ and no rounding is performed. As an exception, the C version may raise\n\ ...@@ -107,36 +114,39 @@ and no rounding is performed. As an exception, the C version may raise\n\
InvalidOperation if the second operand cannot be converted exactly.\n\ InvalidOperation if the second operand cannot be converted exactly.\n\
\n"); \n");
PyDoc_STRVAR(doc_compare_total_mag,"\n\ PyDoc_STRVAR(doc_compare_total_mag,
compare_total_mag(other, context=None) - Compare two operands using their\n\ "compare_total_mag($self, /, other, context=None)\n--\n\n\
abstract representation rather than their value as in compare_total(), but\n\ Compare two operands using their abstract representation rather than their\n\
ignoring the sign of each operand. x.compare_total_mag(y) is equivalent to\n\ value as in compare_total(), but ignoring the sign of each operand.\n\
x.copy_abs().compare_total(y.copy_abs()).\n\ \n\
x.compare_total_mag(y) is equivalent to x.copy_abs().compare_total(y.copy_abs()).\n\
\n\ \n\
This operation is unaffected by context and is quiet: no flags are changed\n\ This operation is unaffected by context and is quiet: no flags are changed\n\
and no rounding is performed. As an exception, the C version may raise\n\ and no rounding is performed. As an exception, the C version may raise\n\
InvalidOperation if the second operand cannot be converted exactly.\n\ InvalidOperation if the second operand cannot be converted exactly.\n\
\n"); \n");
PyDoc_STRVAR(doc_conjugate,"\n\ PyDoc_STRVAR(doc_conjugate,
conjugate() - Return self.\n\ "conjugate($self, /)\n--\n\n\
Return self.\n\
\n"); \n");
PyDoc_STRVAR(doc_copy_abs,"\n\ PyDoc_STRVAR(doc_copy_abs,
copy_abs() - Return the absolute value of the argument. This operation\n\ "copy_abs($self, /)\n--\n\n\
is unaffected by context and is quiet: no flags are changed and no rounding\n\ Return the absolute value of the argument. This operation is unaffected by\n\
is performed.\n\ context and is quiet: no flags are changed and no rounding is performed.\n\
\n"); \n");
PyDoc_STRVAR(doc_copy_negate,"\n\ PyDoc_STRVAR(doc_copy_negate,
copy_negate() - Return the negation of the argument. This operation is\n\ "copy_negate($self, /)\n--\n\n\
unaffected by context and is quiet: no flags are changed and no rounding\n\ Return the negation of the argument. This operation is unaffected by context\n\
is performed.\n\ and is quiet: no flags are changed and no rounding is performed.\n\
\n"); \n");
PyDoc_STRVAR(doc_copy_sign,"\n\ PyDoc_STRVAR(doc_copy_sign,
copy_sign(other, context=None) - Return a copy of the first operand with\n\ "copy_sign($self, /, other, context=None)\n--\n\n\
the sign set to be the same as the sign of the second operand. For example:\n\ Return a copy of the first operand with the sign set to be the same as the\n\
sign of the second operand. For example:\n\
\n\ \n\
>>> Decimal('2.3').copy_sign(Decimal('-1.5'))\n\ >>> Decimal('2.3').copy_sign(Decimal('-1.5'))\n\
Decimal('-2.3')\n\ Decimal('-2.3')\n\
...@@ -146,14 +156,16 @@ and no rounding is performed. As an exception, the C version may raise\n\ ...@@ -146,14 +156,16 @@ and no rounding is performed. As an exception, the C version may raise\n\
InvalidOperation if the second operand cannot be converted exactly.\n\ InvalidOperation if the second operand cannot be converted exactly.\n\
\n"); \n");
PyDoc_STRVAR(doc_exp,"\n\ PyDoc_STRVAR(doc_exp,
exp(context=None) - Return the value of the (natural) exponential function\n\ "exp($self, /, context=None)\n--\n\n\
e**x at the given number. The function always uses the ROUND_HALF_EVEN mode\n\ Return the value of the (natural) exponential function e**x at the given\n\
and the result is correctly rounded.\n\ number. The function always uses the ROUND_HALF_EVEN mode and the result\n\
is correctly rounded.\n\
\n"); \n");
PyDoc_STRVAR(doc_from_float,"\n\ PyDoc_STRVAR(doc_from_float,
from_float(f) - Class method that converts a float to a decimal number, exactly.\n\ "from_float($cls, f, /)\n--\n\n\
Class method that converts a float to a decimal number, exactly.\n\
Since 0.1 is not exactly representable in binary floating point,\n\ Since 0.1 is not exactly representable in binary floating point,\n\
Decimal.from_float(0.1) is not the same as Decimal('0.1').\n\ Decimal.from_float(0.1) is not the same as Decimal('0.1').\n\
\n\ \n\
...@@ -168,155 +180,176 @@ Decimal.from_float(0.1) is not the same as Decimal('0.1').\n\ ...@@ -168,155 +180,176 @@ Decimal.from_float(0.1) is not the same as Decimal('0.1').\n\
\n\ \n\
\n"); \n");
PyDoc_STRVAR(doc_fma,"\n\ PyDoc_STRVAR(doc_fma,
fma(other, third, context=None) - Fused multiply-add. Return self*other+third\n\ "fma($self, /, other, third, context=None)\n--\n\n\
with no rounding of the intermediate product self*other.\n\ Fused multiply-add. Return self*other+third with no rounding of the\n\
intermediate product self*other.\n\
\n\ \n\
>>> Decimal(2).fma(3, 5)\n\ >>> Decimal(2).fma(3, 5)\n\
Decimal('11')\n\ Decimal('11')\n\
\n\ \n\
\n"); \n");
PyDoc_STRVAR(doc_is_canonical,"\n\ PyDoc_STRVAR(doc_is_canonical,
is_canonical() - Return True if the argument is canonical and False otherwise.\n\ "is_canonical($self, /)\n--\n\n\
Currently, a Decimal instance is always canonical, so this operation always\n\ Return True if the argument is canonical and False otherwise. Currently,\n\
returns True.\n\ a Decimal instance is always canonical, so this operation always returns\n\
True.\n\
\n"); \n");
PyDoc_STRVAR(doc_is_finite,"\n\ PyDoc_STRVAR(doc_is_finite,
is_finite() - Return True if the argument is a finite number, and False if the\n\ "is_finite($self, /)\n--\n\n\
argument is infinite or a NaN.\n\ Return True if the argument is a finite number, and False if the argument\n\
is infinite or a NaN.\n\
\n"); \n");
PyDoc_STRVAR(doc_is_infinite,"\n\ PyDoc_STRVAR(doc_is_infinite,
is_infinite() - Return True if the argument is either positive or negative\n\ "is_infinite($self, /)\n--\n\n\
infinity and False otherwise.\n\ Return True if the argument is either positive or negative infinity and\n\
False otherwise.\n\
\n"); \n");
PyDoc_STRVAR(doc_is_nan,"\n\ PyDoc_STRVAR(doc_is_nan,
is_nan() - Return True if the argument is a (quiet or signaling) NaN and\n\ "is_nan($self, /)\n--\n\n\
False otherwise.\n\ Return True if the argument is a (quiet or signaling) NaN and False\n\
otherwise.\n\
\n"); \n");
PyDoc_STRVAR(doc_is_normal,"\n\ PyDoc_STRVAR(doc_is_normal,
is_normal(context=None) - Return True if the argument is a normal finite\n\ "is_normal($self, /, context=None)\n--\n\n\
non-zero number with an adjusted exponent greater than or equal to Emin.\n\ Return True if the argument is a normal finite non-zero number with an\n\
Return False if the argument is zero, subnormal, infinite or a NaN.\n\ adjusted exponent greater than or equal to Emin. Return False if the\n\
argument is zero, subnormal, infinite or a NaN.\n\
\n"); \n");
PyDoc_STRVAR(doc_is_qnan,"\n\ PyDoc_STRVAR(doc_is_qnan,
is_qnan() - Return True if the argument is a quiet NaN, and False otherwise.\n\ "is_qnan($self, /)\n--\n\n\
Return True if the argument is a quiet NaN, and False otherwise.\n\
\n"); \n");
PyDoc_STRVAR(doc_is_signed,"\n\ PyDoc_STRVAR(doc_is_signed,
is_signed() - Return True if the argument has a negative sign and\n\ "is_signed($self, /)\n--\n\n\
False otherwise. Note that both zeros and NaNs can carry signs.\n\ Return True if the argument has a negative sign and False otherwise.\n\
Note that both zeros and NaNs can carry signs.\n\
\n"); \n");
PyDoc_STRVAR(doc_is_snan,"\n\ PyDoc_STRVAR(doc_is_snan,
is_snan() - Return True if the argument is a signaling NaN and False otherwise.\n\ "is_snan($self, /)\n--\n\n\
Return True if the argument is a signaling NaN and False otherwise.\n\
\n"); \n");
PyDoc_STRVAR(doc_is_subnormal,"\n\ PyDoc_STRVAR(doc_is_subnormal,
is_subnormal(context=None) - Return True if the argument is subnormal, and\n\ "is_subnormal($self, /, context=None)\n--\n\n\
False otherwise. A number is subnormal if it is non-zero, finite, and has an\n\ Return True if the argument is subnormal, and False otherwise. A number is\n\
adjusted exponent less than Emin.\n\ subnormal if it is non-zero, finite, and has an adjusted exponent less\n\
than Emin.\n\
\n"); \n");
PyDoc_STRVAR(doc_is_zero,"\n\ PyDoc_STRVAR(doc_is_zero,
is_zero() - Return True if the argument is a (positive or negative) zero and\n\ "is_zero($self, /)\n--\n\n\
False otherwise.\n\ Return True if the argument is a (positive or negative) zero and False\n\
otherwise.\n\
\n"); \n");
PyDoc_STRVAR(doc_ln,"\n\ PyDoc_STRVAR(doc_ln,
ln(context=None) - Return the natural (base e) logarithm of the operand.\n\ "ln($self, /, context=None)\n--\n\n\
The function always uses the ROUND_HALF_EVEN mode and the result is\n\ Return the natural (base e) logarithm of the operand. The function always\n\
correctly rounded.\n\ uses the ROUND_HALF_EVEN mode and the result is correctly rounded.\n\
\n"); \n");
PyDoc_STRVAR(doc_log10,"\n\ PyDoc_STRVAR(doc_log10,
log10(context=None) - Return the base ten logarithm of the operand.\n\ "log10($self, /, context=None)\n--\n\n\
The function always uses the ROUND_HALF_EVEN mode and the result is\n\ Return the base ten logarithm of the operand. The function always uses the\n\
correctly rounded.\n\ ROUND_HALF_EVEN mode and the result is correctly rounded.\n\
\n"); \n");
PyDoc_STRVAR(doc_logb,"\n\ PyDoc_STRVAR(doc_logb,
logb(context=None) - For a non-zero number, return the adjusted exponent\n\ "logb($self, /, context=None)\n--\n\n\
of the operand as a Decimal instance. If the operand is a zero, then\n\ For a non-zero number, return the adjusted exponent of the operand as a\n\
Decimal('-Infinity') is returned and the DivisionByZero condition is\n\ Decimal instance. If the operand is a zero, then Decimal('-Infinity') is\n\
raised. If the operand is an infinity then Decimal('Infinity') is returned.\n\ returned and the DivisionByZero condition is raised. If the operand is\n\
an infinity then Decimal('Infinity') is returned.\n\
\n"); \n");
PyDoc_STRVAR(doc_logical_and,"\n\ PyDoc_STRVAR(doc_logical_and,
logical_and(other, context=None) - Return the digit-wise and of the two\n\ "logical_and($self, /, other, context=None)\n--\n\n\
(logical) operands.\n\ Return the digit-wise 'and' of the two (logical) operands.\n\
\n"); \n");
PyDoc_STRVAR(doc_logical_invert,"\n\ PyDoc_STRVAR(doc_logical_invert,
logical_invert(context=None) - Return the digit-wise inversion of the\n\ "logical_invert($self, /, context=None)\n--\n\n\
(logical) operand.\n\ Return the digit-wise inversion of the (logical) operand.\n\
\n"); \n");
PyDoc_STRVAR(doc_logical_or,"\n\ PyDoc_STRVAR(doc_logical_or,
logical_or(other, context=None) - Return the digit-wise or of the two\n\ "logical_or($self, /, other, context=None)\n--\n\n\
(logical) operands.\n\ Return the digit-wise 'or' of the two (logical) operands.\n\
\n"); \n");
PyDoc_STRVAR(doc_logical_xor,"\n\ PyDoc_STRVAR(doc_logical_xor,
logical_xor(other, context=None) - Return the digit-wise exclusive or of the\n\ "logical_xor($self, /, other, context=None)\n--\n\n\
two (logical) operands.\n\ Return the digit-wise 'exclusive or' of the two (logical) operands.\n\
\n"); \n");
PyDoc_STRVAR(doc_max,"\n\ PyDoc_STRVAR(doc_max,
max(other, context=None) - Maximum of self and other. If one operand is a\n\ "max($self, /, other, context=None)\n--\n\n\
quiet NaN and the other is numeric, the numeric operand is returned.\n\ Maximum of self and other. If one operand is a quiet NaN and the other is\n\
numeric, the numeric operand is returned.\n\
\n"); \n");
PyDoc_STRVAR(doc_max_mag,"\n\ PyDoc_STRVAR(doc_max_mag,
max_mag(other, context=None) - Similar to the max() method, but the\n\ "max_mag($self, /, other, context=None)\n--\n\n\
comparison is done using the absolute values of the operands.\n\ Similar to the max() method, but the comparison is done using the absolute\n\
values of the operands.\n\
\n"); \n");
PyDoc_STRVAR(doc_min,"\n\ PyDoc_STRVAR(doc_min,
min(other, context=None) - Minimum of self and other. If one operand is a\n\ "min($self, /, other, context=None)\n--\n\n\
quiet NaN and the other is numeric, the numeric operand is returned.\n\ Minimum of self and other. If one operand is a quiet NaN and the other is\n\
numeric, the numeric operand is returned.\n\
\n"); \n");
PyDoc_STRVAR(doc_min_mag,"\n\ PyDoc_STRVAR(doc_min_mag,
min_mag(other, context=None) - Similar to the min() method, but the\n\ "min_mag($self, /, other, context=None)\n--\n\n\
comparison is done using the absolute values of the operands.\n\ Similar to the min() method, but the comparison is done using the absolute\n\
values of the operands.\n\
\n"); \n");
PyDoc_STRVAR(doc_next_minus,"\n\ PyDoc_STRVAR(doc_next_minus,
next_minus(context=None) - Return the largest number representable in the\n\ "next_minus($self, /, context=None)\n--\n\n\
given context (or in the current default context if no context is given) that\n\ Return the largest number representable in the given context (or in the\n\
is smaller than the given operand.\n\ current default context if no context is given) that is smaller than the\n\
given operand.\n\
\n"); \n");
PyDoc_STRVAR(doc_next_plus,"\n\ PyDoc_STRVAR(doc_next_plus,
next_plus(context=None) - Return the smallest number representable in the\n\ "next_plus($self, /, context=None)\n--\n\n\
given context (or in the current default context if no context is given) that\n\ Return the smallest number representable in the given context (or in the\n\
is larger than the given operand.\n\ current default context if no context is given) that is larger than the\n\
given operand.\n\
\n"); \n");
PyDoc_STRVAR(doc_next_toward,"\n\ PyDoc_STRVAR(doc_next_toward,
next_toward(other, context=None) - If the two operands are unequal, return\n\ "next_toward($self, /, other, context=None)\n--\n\n\
the number closest to the first operand in the direction of the second operand.\n\ If the two operands are unequal, return the number closest to the first\n\
If both operands are numerically equal, return a copy of the first operand\n\ operand in the direction of the second operand. If both operands are\n\
with the sign set to be the same as the sign of the second operand.\n\ numerically equal, return a copy of the first operand with the sign set\n\
to be the same as the sign of the second operand.\n\
\n"); \n");
PyDoc_STRVAR(doc_normalize,"\n\ PyDoc_STRVAR(doc_normalize,
normalize(context=None) - Normalize the number by stripping the rightmost\n\ "normalize($self, /, context=None)\n--\n\n\
trailing zeros and converting any result equal to Decimal('0') to Decimal('0e0').\n\ Normalize the number by stripping the rightmost trailing zeros and\n\
Used for producing canonical values for members of an equivalence class. For\n\ converting any result equal to Decimal('0') to Decimal('0e0'). Used\n\
example, Decimal('32.100') and Decimal('0.321000e+2') both normalize to the\n\ for producing canonical values for members of an equivalence class.\n\
equivalent value Decimal('32.1').\n\ For example, Decimal('32.100') and Decimal('0.321000e+2') both normalize\n\
to the equivalent value Decimal('32.1').\n\
\n"); \n");
PyDoc_STRVAR(doc_number_class,"\n\ PyDoc_STRVAR(doc_number_class,
number_class(context=None) - Return a string describing the class of the\n\ "number_class($self, /, context=None)\n--\n\n\
operand. The returned value is one of the following ten strings:\n\ Return a string describing the class of the operand. The returned value\n\
is one of the following ten strings:\n\
\n\ \n\
* '-Infinity', indicating that the operand is negative infinity.\n\ * '-Infinity', indicating that the operand is negative infinity.\n\
* '-Normal', indicating that the operand is a negative normal number.\n\ * '-Normal', indicating that the operand is a negative normal number.\n\
...@@ -331,9 +364,10 @@ operand. The returned value is one of the following ten strings:\n\ ...@@ -331,9 +364,10 @@ operand. The returned value is one of the following ten strings:\n\
\n\ \n\
\n"); \n");
PyDoc_STRVAR(doc_quantize,"\n\ PyDoc_STRVAR(doc_quantize,
quantize(exp, rounding=None, context=None) - Return a value equal to the\n\ "quantize($self, /, exp, rounding=None, context=None)\n--\n\n\
first operand after rounding and having the exponent of the second operand.\n\ Return a value equal to the first operand after rounding and having the\n\
exponent of the second operand.\n\
\n\ \n\
>>> Decimal('1.41421356').quantize(Decimal('1.000'))\n\ >>> Decimal('1.41421356').quantize(Decimal('1.000'))\n\
Decimal('1.414')\n\ Decimal('1.414')\n\
...@@ -352,93 +386,98 @@ rounding argument if given, else by the given context argument; if neither\n\ ...@@ -352,93 +386,98 @@ rounding argument if given, else by the given context argument; if neither\n\
argument is given, the rounding mode of the current thread's context is used.\n\ argument is given, the rounding mode of the current thread's context is used.\n\
\n"); \n");
PyDoc_STRVAR(doc_radix,"\n\ PyDoc_STRVAR(doc_radix,
radix() - Return Decimal(10), the radix (base) in which the Decimal class does\n\ "radix($self, /)\n--\n\n\
Return Decimal(10), the radix (base) in which the Decimal class does\n\
all its arithmetic. Included for compatibility with the specification.\n\ all its arithmetic. Included for compatibility with the specification.\n\
\n"); \n");
PyDoc_STRVAR(doc_remainder_near,"\n\ PyDoc_STRVAR(doc_remainder_near,
remainder_near(other, context=None) - Return the remainder from dividing\n\ "remainder_near($self, /, other, context=None)\n--\n\n\
self by other. This differs from self % other in that the sign of the\n\ Return the remainder from dividing self by other. This differs from\n\
remainder is chosen so as to minimize its absolute value. More precisely, the\n\ self % other in that the sign of the remainder is chosen so as to minimize\n\
return value is self - n * other where n is the integer nearest to the exact\n\ its absolute value. More precisely, the return value is self - n * other\n\
value of self / other, and if two integers are equally near then the even one\n\ where n is the integer nearest to the exact value of self / other, and\n\
is chosen.\n\ if two integers are equally near then the even one is chosen.\n\
\n\ \n\
If the result is zero then its sign will be the sign of self.\n\ If the result is zero then its sign will be the sign of self.\n\
\n"); \n");
PyDoc_STRVAR(doc_rotate,"\n\ PyDoc_STRVAR(doc_rotate,
rotate(other, context=None) - Return the result of rotating the digits of the\n\ "rotate($self, /, other, context=None)\n--\n\n\
first operand by an amount specified by the second operand. The second operand\n\ Return the result of rotating the digits of the first operand by an amount\n\
must be an integer in the range -precision through precision. The absolute\n\ specified by the second operand. The second operand must be an integer in\n\
value of the second operand gives the number of places to rotate. If the second\n\ the range -precision through precision. The absolute value of the second\n\
operand is positive then rotation is to the left; otherwise rotation is to the\n\ operand gives the number of places to rotate. If the second operand is\n\
right. The coefficient of the first operand is padded on the left with zeros to\n\ positive then rotation is to the left; otherwise rotation is to the right.\n\
The coefficient of the first operand is padded on the left with zeros to\n\
length precision if necessary. The sign and exponent of the first operand are\n\ length precision if necessary. The sign and exponent of the first operand are\n\
unchanged.\n\ unchanged.\n\
\n"); \n");
PyDoc_STRVAR(doc_same_quantum,"\n\ PyDoc_STRVAR(doc_same_quantum,
same_quantum(other, context=None) - Test whether self and other have the\n\ "same_quantum($self, /, other, context=None)\n--\n\n\
same exponent or whether both are NaN.\n\ Test whether self and other have the same exponent or whether both are NaN.\n\
\n\ \n\
This operation is unaffected by context and is quiet: no flags are changed\n\ This operation is unaffected by context and is quiet: no flags are changed\n\
and no rounding is performed. As an exception, the C version may raise\n\ and no rounding is performed. As an exception, the C version may raise\n\
InvalidOperation if the second operand cannot be converted exactly.\n\ InvalidOperation if the second operand cannot be converted exactly.\n\
\n"); \n");
PyDoc_STRVAR(doc_scaleb,"\n\ PyDoc_STRVAR(doc_scaleb,
scaleb(other, context=None) - Return the first operand with the exponent\n\ "scaleb($self, /, other, context=None)\n--\n\n\
adjusted the second. Equivalently, return the first operand multiplied by\n\ Return the first operand with the exponent adjusted the second. Equivalently,\n\
10**other. The second operand must be an integer.\n\ return the first operand multiplied by 10**other. The second operand must be\n\
an integer.\n\
\n"); \n");
PyDoc_STRVAR(doc_shift,"\n\ PyDoc_STRVAR(doc_shift,
shift(other, context=None) - Return the result of shifting the digits of\n\ "shift($self, /, other, context=None)\n--\n\n\
the first operand by an amount specified by the second operand. The second\n\ Return the result of shifting the digits of the first operand by an amount\n\
operand must be an integer in the range -precision through precision. The\n\ specified by the second operand. The second operand must be an integer in\n\
absolute value of the second operand gives the number of places to shift.\n\ the range -precision through precision. The absolute value of the second\n\
If the second operand is positive, then the shift is to the left; otherwise\n\ operand gives the number of places to shift. If the second operand is\n\
the shift is to the right. Digits shifted into the coefficient are zeros.\n\ positive, then the shift is to the left; otherwise the shift is to the\n\
The sign and exponent of the first operand are unchanged.\n\ right. Digits shifted into the coefficient are zeros. The sign and exponent\n\
of the first operand are unchanged.\n\
\n"); \n");
PyDoc_STRVAR(doc_sqrt,"\n\ PyDoc_STRVAR(doc_sqrt,
sqrt(context=None) - Return the square root of the argument to full precision.\n\ "sqrt($self, /, context=None)\n--\n\n\
The result is correctly rounded using the ROUND_HALF_EVEN rounding mode.\n\ Return the square root of the argument to full precision. The result is\n\
correctly rounded using the ROUND_HALF_EVEN rounding mode.\n\
\n"); \n");
PyDoc_STRVAR(doc_to_eng_string,"\n\ PyDoc_STRVAR(doc_to_eng_string,
to_eng_string(context=None) - Convert to an engineering-type string.\n\ "to_eng_string($self, /, context=None)\n--\n\n\
Engineering notation has an exponent which is a multiple of 3, so there\n\ Convert to an engineering-type string. Engineering notation has an exponent\n\
are up to 3 digits left of the decimal place. For example, Decimal('123E+1')\n\ which is a multiple of 3, so there are up to 3 digits left of the decimal\n\
is converted to Decimal('1.23E+3').\n\ place. For example, Decimal('123E+1') is converted to Decimal('1.23E+3').\n\
\n\ \n\
The value of context.capitals determines whether the exponent sign is lower\n\ The value of context.capitals determines whether the exponent sign is lower\n\
or upper case. Otherwise, the context does not affect the operation.\n\ or upper case. Otherwise, the context does not affect the operation.\n\
\n"); \n");
PyDoc_STRVAR(doc_to_integral,"\n\ PyDoc_STRVAR(doc_to_integral,
to_integral(rounding=None, context=None) - Identical to the\n\ "to_integral($self, /, rounding=None, context=None)\n--\n\n\
to_integral_value() method. The to_integral() name has been kept\n\ Identical to the to_integral_value() method. The to_integral() name has been\n\
for compatibility with older versions.\n\ kept for compatibility with older versions.\n\
\n"); \n");
PyDoc_STRVAR(doc_to_integral_exact,"\n\ PyDoc_STRVAR(doc_to_integral_exact,
to_integral_exact(rounding=None, context=None) - Round to the nearest\n\ "to_integral_exact($self, /, rounding=None, context=None)\n--\n\n\
integer, signaling Inexact or Rounded as appropriate if rounding occurs.\n\ Round to the nearest integer, signaling Inexact or Rounded as appropriate if\n\
The rounding mode is determined by the rounding parameter if given, else\n\ rounding occurs. The rounding mode is determined by the rounding parameter\n\
by the given context. If neither parameter is given, then the rounding mode\n\ if given, else by the given context. If neither parameter is given, then the\n\
of the current default context is used.\n\ rounding mode of the current default context is used.\n\
\n"); \n");
PyDoc_STRVAR(doc_to_integral_value,"\n\ PyDoc_STRVAR(doc_to_integral_value,
to_integral_value(rounding=None, context=None) - Round to the nearest\n\ "to_integral_value($self, /, rounding=None, context=None)\n--\n\n\
integer without signaling Inexact or Rounded. The rounding mode is determined\n\ Round to the nearest integer without signaling Inexact or Rounded. The\n\
by the rounding parameter if given, else by the given context. If neither\n\ rounding mode is determined by the rounding parameter if given, else by\n\
parameter is given, then the rounding mode of the current default context is\n\ the given context. If neither parameter is given, then the rounding mode\n\
used.\n\ of the current default context is used.\n\
\n"); \n");
...@@ -446,7 +485,8 @@ used.\n\ ...@@ -446,7 +485,8 @@ used.\n\
/* Context Object and Methods */ /* Context Object and Methods */
/******************************************************************************/ /******************************************************************************/
PyDoc_STRVAR(doc_context,"\n\ PyDoc_STRVAR(doc_context,
"Context(prec=None, rounding=None, Emin=None, Emax=None, capitals=None, clamp=None, flags=None, traps=None)\n--\n\n\
The context affects almost all operations and controls rounding,\n\ The context affects almost all operations and controls rounding,\n\
Over/Underflow, raising of exceptions and much more. A new context\n\ Over/Underflow, raising of exceptions and much more. A new context\n\
can be constructed as follows:\n\ can be constructed as follows:\n\
...@@ -460,308 +500,372 @@ can be constructed as follows:\n\ ...@@ -460,308 +500,372 @@ can be constructed as follows:\n\
\n"); \n");
#ifdef EXTRA_FUNCTIONALITY #ifdef EXTRA_FUNCTIONALITY
PyDoc_STRVAR(doc_ctx_apply,"\n\ PyDoc_STRVAR(doc_ctx_apply,
apply(x) - Apply self to Decimal x.\n\ "apply($self, x, /)\n--\n\n\
Apply self to Decimal x.\n\
\n"); \n");
#endif #endif
PyDoc_STRVAR(doc_ctx_clear_flags,"\n\ PyDoc_STRVAR(doc_ctx_clear_flags,
clear_flags() - Reset all flags to False.\n\ "clear_flags($self, /)\n--\n\n\
Reset all flags to False.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_clear_traps,"\n\ PyDoc_STRVAR(doc_ctx_clear_traps,
clear_traps() - Set all traps to False.\n\ "clear_traps($self, /)\n--\n\n\
Set all traps to False.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_copy,"\n\ PyDoc_STRVAR(doc_ctx_copy,
copy() - Return a duplicate of the context with all flags cleared.\n\ "copy($self, /)\n--\n\n\
Return a duplicate of the context with all flags cleared.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_copy_decimal,"\n\ PyDoc_STRVAR(doc_ctx_copy_decimal,
copy_decimal(x) - Return a copy of Decimal x.\n\ "copy_decimal($self, x, /)\n--\n\n\
Return a copy of Decimal x.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_create_decimal,"\n\ PyDoc_STRVAR(doc_ctx_create_decimal,
create_decimal(x) - Create a new Decimal instance from x, using self as the\n\ "create_decimal($self, num=\"0\", /)\n--\n\n\
context. Unlike the Decimal constructor, this function observes the context\n\ Create a new Decimal instance from num, using self as the context. Unlike the\n\
limits.\n\ Decimal constructor, this function observes the context limits.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_create_decimal_from_float,"\n\ PyDoc_STRVAR(doc_ctx_create_decimal_from_float,
create_decimal_from_float(f) - Create a new Decimal instance from float f.\n\ "create_decimal_from_float($self, f, /)\n--\n\n\
Unlike the Decimal.from_float() class method, this function observes the\n\ Create a new Decimal instance from float f. Unlike the Decimal.from_float()\n\
context limits.\n\ class method, this function observes the context limits.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_Etiny,"\n\ PyDoc_STRVAR(doc_ctx_Etiny,
Etiny() - Return a value equal to Emin - prec + 1, which is the minimum\n\ "Etiny($self, /)\n--\n\n\
exponent value for subnormal results. When underflow occurs, the exponent\n\ Return a value equal to Emin - prec + 1, which is the minimum exponent value\n\
is set to Etiny.\n\ for subnormal results. When underflow occurs, the exponent is set to Etiny.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_Etop,"\n\ PyDoc_STRVAR(doc_ctx_Etop,
Etop() - Return a value equal to Emax - prec + 1. This is the maximum exponent\n\ "Etop($self, /)\n--\n\n\
if the _clamp field of the context is set to 1 (IEEE clamp mode). Etop() must\n\ Return a value equal to Emax - prec + 1. This is the maximum exponent\n\
not be negative.\n\ if the _clamp field of the context is set to 1 (IEEE clamp mode). Etop()\n\
must not be negative.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_abs,"\n\ PyDoc_STRVAR(doc_ctx_abs,
abs(x) - Return the absolute value of x.\n\ "abs($self, x, /)\n--\n\n\
Return the absolute value of x.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_add,"\n\ PyDoc_STRVAR(doc_ctx_add,
add(x, y) - Return the sum of x and y.\n\ "add($self, x, y, /)\n--\n\n\
Return the sum of x and y.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_canonical,"\n\ PyDoc_STRVAR(doc_ctx_canonical,
canonical(x) - Return a new instance of x.\n\ "canonical($self, x, /)\n--\n\n\
Return a new instance of x.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_compare,"\n\ PyDoc_STRVAR(doc_ctx_compare,
compare(x, y) - Compare x and y numerically.\n\ "compare($self, x, y, /)\n--\n\n\
Compare x and y numerically.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_compare_signal,"\n\ PyDoc_STRVAR(doc_ctx_compare_signal,
compare_signal(x, y) - Compare x and y numerically. All NaNs signal.\n\ "compare_signal($self, x, y, /)\n--\n\n\
Compare x and y numerically. All NaNs signal.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_compare_total,"\n\ PyDoc_STRVAR(doc_ctx_compare_total,
compare_total(x, y) - Compare x and y using their abstract representation.\n\ "compare_total($self, x, y, /)\n--\n\n\
Compare x and y using their abstract representation.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_compare_total_mag,"\n\ PyDoc_STRVAR(doc_ctx_compare_total_mag,
compare_total_mag(x, y) - Compare x and y using their abstract representation,\n\ "compare_total_mag($self, x, y, /)\n--\n\n\
ignoring sign.\n\ Compare x and y using their abstract representation, ignoring sign.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_copy_abs,"\n\ PyDoc_STRVAR(doc_ctx_copy_abs,
copy_abs(x) - Return a copy of x with the sign set to 0.\n\ "copy_abs($self, x, /)\n--\n\n\
Return a copy of x with the sign set to 0.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_copy_negate,"\n\ PyDoc_STRVAR(doc_ctx_copy_negate,
copy_negate(x) - Return a copy of x with the sign inverted.\n\ "copy_negate($self, x, /)\n--\n\n\
Return a copy of x with the sign inverted.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_copy_sign,"\n\ PyDoc_STRVAR(doc_ctx_copy_sign,
copy_sign(x, y) - Copy the sign from y to x.\n\ "copy_sign($self, x, y, /)\n--\n\n\
Copy the sign from y to x.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_divide,"\n\ PyDoc_STRVAR(doc_ctx_divide,
divide(x, y) - Return x divided by y.\n\ "divide($self, x, y, /)\n--\n\n\
Return x divided by y.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_divide_int,"\n\ PyDoc_STRVAR(doc_ctx_divide_int,
divide_int(x, y) - Return x divided by y, truncated to an integer.\n\ "divide_int($self, x, y, /)\n--\n\n\
Return x divided by y, truncated to an integer.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_divmod,"\n\ PyDoc_STRVAR(doc_ctx_divmod,
divmod(x, y) - Return quotient and remainder of the division x / y.\n\ "divmod($self, x, y, /)\n--\n\n\
Return quotient and remainder of the division x / y.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_exp,"\n\ PyDoc_STRVAR(doc_ctx_exp,
exp(x) - Return e ** x.\n\ "exp($self, x, /)\n--\n\n\
Return e ** x.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_fma,"\n\ PyDoc_STRVAR(doc_ctx_fma,
fma(x, y, z) - Return x multiplied by y, plus z.\n\ "fma($self, x, y, z, /)\n--\n\n\
Return x multiplied by y, plus z.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_is_canonical,"\n\ PyDoc_STRVAR(doc_ctx_is_canonical,
is_canonical(x) - Return True if x is canonical, False otherwise.\n\ "is_canonical($self, x, /)\n--\n\n\
Return True if x is canonical, False otherwise.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_is_finite,"\n\ PyDoc_STRVAR(doc_ctx_is_finite,
is_finite(x) - Return True if x is finite, False otherwise.\n\ "is_finite($self, x, /)\n--\n\n\
Return True if x is finite, False otherwise.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_is_infinite,"\n\ PyDoc_STRVAR(doc_ctx_is_infinite,
is_infinite(x) - Return True if x is infinite, False otherwise.\n\ "is_infinite($self, x, /)\n--\n\n\
Return True if x is infinite, False otherwise.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_is_nan,"\n\ PyDoc_STRVAR(doc_ctx_is_nan,
is_nan(x) - Return True if x is a qNaN or sNaN, False otherwise.\n\ "is_nan($self, x, /)\n--\n\n\
Return True if x is a qNaN or sNaN, False otherwise.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_is_normal,"\n\ PyDoc_STRVAR(doc_ctx_is_normal,
is_normal(x) - Return True if x is a normal number, False otherwise.\n\ "is_normal($self, x, /)\n--\n\n\
Return True if x is a normal number, False otherwise.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_is_qnan,"\n\ PyDoc_STRVAR(doc_ctx_is_qnan,
is_qnan(x) - Return True if x is a quiet NaN, False otherwise.\n\ "is_qnan($self, x, /)\n--\n\n\
Return True if x is a quiet NaN, False otherwise.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_is_signed,"\n\ PyDoc_STRVAR(doc_ctx_is_signed,
is_signed(x) - Return True if x is negative, False otherwise.\n\ "is_signed($self, x, /)\n--\n\n\
Return True if x is negative, False otherwise.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_is_snan,"\n\ PyDoc_STRVAR(doc_ctx_is_snan,
is_snan() - Return True if x is a signaling NaN, False otherwise.\n\ "is_snan($self, x, /)\n--\n\n\
Return True if x is a signaling NaN, False otherwise.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_is_subnormal,"\n\ PyDoc_STRVAR(doc_ctx_is_subnormal,
is_subnormal(x) - Return True if x is subnormal, False otherwise.\n\ "is_subnormal($self, x, /)\n--\n\n\
Return True if x is subnormal, False otherwise.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_is_zero,"\n\ PyDoc_STRVAR(doc_ctx_is_zero,
is_zero(x) - Return True if x is a zero, False otherwise.\n\ "is_zero($self, x, /)\n--\n\n\
Return True if x is a zero, False otherwise.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_ln,"\n\ PyDoc_STRVAR(doc_ctx_ln,
ln(x) - Return the natural (base e) logarithm of x.\n\ "ln($self, x, /)\n--\n\n\
Return the natural (base e) logarithm of x.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_log10,"\n\ PyDoc_STRVAR(doc_ctx_log10,
log10(x) - Return the base 10 logarithm of x.\n\ "log10($self, x, /)\n--\n\n\
Return the base 10 logarithm of x.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_logb,"\n\ PyDoc_STRVAR(doc_ctx_logb,
logb(x) - Return the exponent of the magnitude of the operand's MSD.\n\ "logb($self, x, /)\n--\n\n\
Return the exponent of the magnitude of the operand's MSD.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_logical_and,"\n\ PyDoc_STRVAR(doc_ctx_logical_and,
logical_and(x, y) - Digit-wise and of x and y.\n\ "logical_and($self, x, y, /)\n--\n\n\
Digit-wise and of x and y.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_logical_invert,"\n\ PyDoc_STRVAR(doc_ctx_logical_invert,
logical_invert(x) - Invert all digits of x.\n\ "logical_invert($self, x, /)\n--\n\n\
Invert all digits of x.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_logical_or,"\n\ PyDoc_STRVAR(doc_ctx_logical_or,
logical_or(x, y) - Digit-wise or of x and y.\n\ "logical_or($self, x, y, /)\n--\n\n\
Digit-wise or of x and y.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_logical_xor,"\n\ PyDoc_STRVAR(doc_ctx_logical_xor,
logical_xor(x, y) - Digit-wise xor of x and y.\n\ "logical_xor($self, x, y, /)\n--\n\n\
Digit-wise xor of x and y.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_max,"\n\ PyDoc_STRVAR(doc_ctx_max,
max(x, y) - Compare the values numerically and return the maximum.\n\ "max($self, x, y, /)\n--\n\n\
Compare the values numerically and return the maximum.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_max_mag,"\n\ PyDoc_STRVAR(doc_ctx_max_mag,
max_mag(x, y) - Compare the values numerically with their sign ignored.\n\ "max_mag($self, x, y, /)\n--\n\n\
Compare the values numerically with their sign ignored.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_min,"\n\ PyDoc_STRVAR(doc_ctx_min,
min(x, y) - Compare the values numerically and return the minimum.\n\ "min($self, x, y, /)\n--\n\n\
Compare the values numerically and return the minimum.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_min_mag,"\n\ PyDoc_STRVAR(doc_ctx_min_mag,
min_mag(x, y) - Compare the values numerically with their sign ignored.\n\ "min_mag($self, x, y, /)\n--\n\n\
Compare the values numerically with their sign ignored.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_minus,"\n\ PyDoc_STRVAR(doc_ctx_minus,
minus(x) - Minus corresponds to the unary prefix minus operator in Python,\n\ "minus($self, x, /)\n--\n\n\
but applies the context to the result.\n\ Minus corresponds to the unary prefix minus operator in Python, but applies\n\
the context to the result.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_multiply,"\n\ PyDoc_STRVAR(doc_ctx_multiply,
multiply(x, y) - Return the product of x and y.\n\ "multiply($self, x, y, /)\n--\n\n\
Return the product of x and y.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_next_minus,"\n\ PyDoc_STRVAR(doc_ctx_next_minus,
next_minus(x) - Return the largest representable number smaller than x.\n\ "next_minus($self, x, /)\n--\n\n\
Return the largest representable number smaller than x.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_next_plus,"\n\ PyDoc_STRVAR(doc_ctx_next_plus,
next_plus(x) - Return the smallest representable number larger than x.\n\ "next_plus($self, x, /)\n--\n\n\
Return the smallest representable number larger than x.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_next_toward,"\n\ PyDoc_STRVAR(doc_ctx_next_toward,
next_toward(x) - Return the number closest to x, in the direction towards y.\n\ "next_toward($self, x, y, /)\n--\n\n\
Return the number closest to x, in the direction towards y.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_normalize,"\n\ PyDoc_STRVAR(doc_ctx_normalize,
normalize(x) - Reduce x to its simplest form. Alias for reduce(x).\n\ "normalize($self, x, /)\n--\n\n\
Reduce x to its simplest form. Alias for reduce(x).\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_number_class,"\n\ PyDoc_STRVAR(doc_ctx_number_class,
number_class(x) - Return an indication of the class of x.\n\ "number_class($self, x, /)\n--\n\n\
Return an indication of the class of x.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_plus,"\n\ PyDoc_STRVAR(doc_ctx_plus,
plus(x) - Plus corresponds to the unary prefix plus operator in Python,\n\ "plus($self, x, /)\n--\n\n\
but applies the context to the result.\n\ Plus corresponds to the unary prefix plus operator in Python, but applies\n\
the context to the result.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_power,"\n\ PyDoc_STRVAR(doc_ctx_power,
power(x, y) - Compute x**y. If x is negative, then y must be integral.\n\ "power($self, /, a, b, modulo=None)\n--\n\n\
The result will be inexact unless y is integral and the result is finite\n\ Compute a**b. If 'a' is negative, then 'b' must be integral. The result\n\
and can be expressed exactly in 'precision' digits. In the Python version\n\ will be inexact unless 'a' is integral and the result is finite and can\n\
the result is always correctly rounded, in the C version the result is\n\ be expressed exactly in 'precision' digits. In the Python version the\n\
almost always correctly rounded.\n\ result is always correctly rounded, in the C version the result is almost\n\
always correctly rounded.\n\
\n\ \n\
power(x, y, m) - Compute (x**y) % m. The following restrictions hold:\n\ If modulo is given, compute (a**b) % modulo. The following restrictions\n\
hold:\n\
\n\ \n\
* all three arguments must be integral\n\ * all three arguments must be integral\n\
* y must be nonnegative\n\ * 'b' must be nonnegative\n\
* at least one of x or y must be nonzero\n\ * at least one of 'a' or 'b' must be nonzero\n\
* m must be nonzero and less than 10**prec in absolute value\n\ * modulo must be nonzero and less than 10**prec in absolute value\n\
\n\ \n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_quantize,"\n\ PyDoc_STRVAR(doc_ctx_quantize,
quantize(x, y) - Return a value equal to x (rounded), having the exponent of y.\n\ "quantize($self, x, y, /)\n--\n\n\
Return a value equal to x (rounded), having the exponent of y.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_radix,"\n\ PyDoc_STRVAR(doc_ctx_radix,
radix() - Return 10.\n\ "radix($self, /)\n--\n\n\
Return 10.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_remainder,"\n\ PyDoc_STRVAR(doc_ctx_remainder,
remainder(x, y) - Return the remainder from integer division. The sign of\n\ "remainder($self, x, y, /)\n--\n\n\
the result, if non-zero, is the same as that of the original dividend.\n\ Return the remainder from integer division. The sign of the result,\n\
if non-zero, is the same as that of the original dividend.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_remainder_near,"\n\ PyDoc_STRVAR(doc_ctx_remainder_near,
remainder_near(x, y) - Return x - y * n, where n is the integer nearest the\n\ "remainder_near($self, x, y, /)\n--\n\n\
exact value of x / y (if the result is 0 then its sign will be the sign of x).\n\ Return x - y * n, where n is the integer nearest the exact value of x / y\n\
(if the result is 0 then its sign will be the sign of x).\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_rotate,"\n\ PyDoc_STRVAR(doc_ctx_rotate,
rotate(x, y) - Return a copy of x, rotated by y places.\n\ "rotate($self, x, y, /)\n--\n\n\
Return a copy of x, rotated by y places.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_same_quantum,"\n\ PyDoc_STRVAR(doc_ctx_same_quantum,
same_quantum(x, y) - Return True if the two operands have the same exponent.\n\ "same_quantum($self, x, y, /)\n--\n\n\
Return True if the two operands have the same exponent.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_scaleb,"\n\ PyDoc_STRVAR(doc_ctx_scaleb,
scaleb(x, y) - Return the first operand after adding the second value\n\ "scaleb($self, x, y, /)\n--\n\n\
to its exp.\n\ Return the first operand after adding the second value to its exp.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_shift,"\n\ PyDoc_STRVAR(doc_ctx_shift,
shift(x, y) - Return a copy of x, shifted by y places.\n\ "shift($self, x, y, /)\n--\n\n\
Return a copy of x, shifted by y places.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_sqrt,"\n\ PyDoc_STRVAR(doc_ctx_sqrt,
sqrt(x) - Square root of a non-negative number to context precision.\n\ "sqrt($self, x, /)\n--\n\n\
Square root of a non-negative number to context precision.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_subtract,"\n\ PyDoc_STRVAR(doc_ctx_subtract,
subtract(x, y) - Return the difference between x and y.\n\ "subtract($self, x, y, /)\n--\n\n\
Return the difference between x and y.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_to_eng_string,"\n\ PyDoc_STRVAR(doc_ctx_to_eng_string,
to_eng_string(x) - Convert a number to a string, using engineering notation.\n\ "to_eng_string($self, x, /)\n--\n\n\
Convert a number to a string, using engineering notation.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_to_integral,"\n\ PyDoc_STRVAR(doc_ctx_to_integral,
to_integral(x) - Identical to to_integral_value(x).\n\ "to_integral($self, x, /)\n--\n\n\
Identical to to_integral_value(x).\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_to_integral_exact,"\n\ PyDoc_STRVAR(doc_ctx_to_integral_exact,
to_integral_exact(x) - Round to an integer. Signal if the result is\n\ "to_integral_exact($self, x, /)\n--\n\n\
rounded or inexact.\n\ Round to an integer. Signal if the result is rounded or inexact.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_to_integral_value,"\n\ PyDoc_STRVAR(doc_ctx_to_integral_value,
to_integral_value(x) - Round to an integer.\n\ "to_integral_value($self, x, /)\n--\n\n\
Round to an integer.\n\
\n"); \n");
PyDoc_STRVAR(doc_ctx_to_sci_string,"\n\ PyDoc_STRVAR(doc_ctx_to_sci_string,
to_sci_string(x) - Convert a number to a string using scientific notation.\n\ "to_sci_string($self, x, /)\n--\n\n\
Convert a number to a string using scientific notation.\n\
\n"); \n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment