gh-111342: fix typo in math.sumprod (GH-111416)

This commit is contained in:
Sergey B Kirpichev 2023-10-28 07:52:04 +03:00 committed by GitHub
parent c3bb10c930
commit 9dc4fb8204
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 1 deletions

View File

@ -1325,6 +1325,7 @@ class MathTests(unittest.TestCase):
sumprod = math.sumprod
self.assertEqual(sumprod([0.1] * 10, [1]*10), 1.0)
self.assertEqual(sumprod([0.1] * 20, [True, False] * 10), 1.0)
self.assertEqual(sumprod([True, False] * 10, [0.1] * 20), 1.0)
self.assertEqual(sumprod([1.0, 10E100, 1.0, -10E100], [1.0]*4), 2.0)
@support.requires_resource('cpu')

View File

@ -0,0 +1 @@
Fixed typo in :func:`math.sumprod`.

View File

@ -2832,7 +2832,7 @@ math_sumprod_impl(PyObject *module, PyObject *p, PyObject *q)
PyErr_Clear();
goto finalize_flt_path;
}
} else if (q_type_float && (PyLong_CheckExact(p_i) || PyBool_Check(q_i))) {
} else if (q_type_float && (PyLong_CheckExact(p_i) || PyBool_Check(p_i))) {
flt_q = PyFloat_AS_DOUBLE(q_i);
flt_p = PyLong_AsDouble(p_i);
if (flt_p == -1.0 && PyErr_Occurred()) {