mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Issue #9165: Add math.isfinite and cmath.isfinite.
This commit is contained in:
parent
3e7428995f
commit
8e0c996873
7 changed files with 61 additions and 0 deletions
|
@ -1023,6 +1023,19 @@ PyDoc_STRVAR(cmath_rect_doc,
|
|||
"rect(r, phi) -> z: complex\n\n\
|
||||
Convert from polar coordinates to rectangular coordinates.");
|
||||
|
||||
static PyObject *
|
||||
cmath_isfinite(PyObject *self, PyObject *args)
|
||||
{
|
||||
Py_complex z;
|
||||
if (!PyArg_ParseTuple(args, "D:isfinite", &z))
|
||||
return NULL;
|
||||
return PyBool_FromLong(Py_IS_FINITE(z.real) && Py_IS_FINITE(z.imag));
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(cmath_isfinite_doc,
|
||||
"isfinite(z) -> bool\n\
|
||||
Return True if both the real and imaginary parts of z are finite, else False.");
|
||||
|
||||
static PyObject *
|
||||
cmath_isnan(PyObject *self, PyObject *args)
|
||||
{
|
||||
|
@ -1065,6 +1078,7 @@ static PyMethodDef cmath_methods[] = {
|
|||
{"cos", cmath_cos, METH_VARARGS, c_cos_doc},
|
||||
{"cosh", cmath_cosh, METH_VARARGS, c_cosh_doc},
|
||||
{"exp", cmath_exp, METH_VARARGS, c_exp_doc},
|
||||
{"isfinite", cmath_isfinite, METH_VARARGS, cmath_isfinite_doc},
|
||||
{"isinf", cmath_isinf, METH_VARARGS, cmath_isinf_doc},
|
||||
{"isnan", cmath_isnan, METH_VARARGS, cmath_isnan_doc},
|
||||
{"log", cmath_log, METH_VARARGS, cmath_log_doc},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue