8000 bpo-33089: Multidimensional math.hypot() by rhettinger · Pull Request #8474 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 21 commits into from
Jul 28, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test for a negative zero input
  • Loading branch information
rhettinger committed Jul 28, 2018
commit d785025402db2f0053a5ade2bf4e122c54023f42
3 changes: 3 additions & 0 deletions Lib/test/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,9 @@ def testHypot(self):
self.assertEqual(hypot(0.0, 0.0), 0.0) # Max input is zero
self.assertEqual(hypot(-10.5), 10.5) # Negative input
Copy link
Member

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)?

Copy link
Contributor Author

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)".

self.assertEqual(hypot(), 0.0) # Negative input
self.assertEqual(1.0,
math.copysign(1.0, hypot(-0.0)) # Convert negative zero to positive zero
)

# Test handling of bad arguments
with self.assertRaises(TypeError): # Reject keyword args
Expand Down
0