-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
bpo-33089: Multidimensional math.hypot() #8474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
ec15283
abce2b0
241932e
51c52fc
de3c16b
18babd4
6c412d2
780024b
d82df99
1a32ac7
82a12e5
2d2e3aa
6edd323
9c25c65
c4dfbe5
0734edd
43471a9
3818324
8298444
d785025
ee1374c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
* Made test for the zero argument case explicit. * Use exactly representable numbers in the extreme small value tests. * Guard against a malicious __float__ that succeeds on the first call and fails on the second.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2068,7 +2068,11 @@ math_hypot(PyObject *self, PyObject *args) | |
| } | ||
| for (i=0 ; i<n ; i++) { | ||
| item = PyTuple_GET_ITEM(args, i); | ||
| x = PyFloat_AsDouble(item) / max; | ||
| x = PyFloat_AsDouble(item); | ||
| if (x == -1.0 && PyErr_Occurred()) { | ||
| return NULL; | ||
| } | ||
| x /= max; | ||
| csum += x * x; | ||
| } | ||
| return PyFloat_FromDouble(max * sqrt(csum)); // XXX Handle overflow | ||
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
self.assertEqual(hypot(), 0.0)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, added an explict test for this case. FWIW, this was already tested in the section "Test different numbers of arguments (from zero to five)".