Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.2k
gh-135853: addmath.fmax
andmath.fmin
#135888
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
math.fmax
andmath.fmin
math.fmax
andmath.fmin
[PoC]Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
0831229
toafb0a91
CompareUh oh!
There was an error while loading.Please reload this page.
math.fmax
andmath.fmin
[PoC]math.fmax
andmath.fmin
Uh oh!
There was an error while loading.Please reload this page.
withself.subTest("math.fmax(INF, x)",x=x): | ||
self.assertEqual(math.fmax(INF,x),INF) | ||
withself.subTest("math.fmax(x, INF)",x=x): | ||
self.assertEqual(math.fmax(x,INF),INF) | ||
withself.subTest("math.fmax(NINF, x)",x=x): | ||
self.assertEqual(math.fmax(NINF,x),x) | ||
withself.subTest("math.fmax(x, NINF)",x=x): | ||
self.assertEqual(math.fmax(x,NINF),x) |
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.
The traceback contains the line causing the assertion failure, I don't think that it's worth it to repeat it it subTest():
withself.subTest("math.fmax(INF, x)",x=x): | |
self.assertEqual(math.fmax(INF,x),INF) | |
withself.subTest("math.fmax(x, INF)",x=x): | |
self.assertEqual(math.fmax(x,INF),INF) | |
withself.subTest("math.fmax(NINF, x)",x=x): | |
self.assertEqual(math.fmax(NINF,x),x) | |
withself.subTest("math.fmax(x, NINF)",x=x): | |
self.assertEqual(math.fmax(x,NINF),x) | |
withself.subTest(x=x): | |
self.assertEqual(math.fmax(INF,x),INF) | |
self.assertEqual(math.fmax(x,INF),INF) | |
self.assertEqual(math.fmax(NINF,x),x) | |
self.assertEqual(math.fmax(x,NINF),x) |
withself.subTest("math.fmax(x, NINF)",x=x): | ||
self.assertEqual(math.fmax(x,NINF),x) | ||
@requires_IEEE_754 |
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.
Python requires IEEE 754 and NaN support to build:https://docs.python.org/dev/using/configure.html#build-requirements We should maybe start getting rid of this decorator?
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.
Other Python implementations may use this test suite as well.
withself.subTest("math.fmin(INF, x)",x=x): | ||
self.assertEqual(math.fmin(INF,x),x) | ||
withself.subTest("math.fmin(x, INF)",x=x): | ||
self.assertEqual(math.fmin(x,INF),x) | ||
withself.subTest("math.fmin(NINF, x)",x=x): | ||
self.assertEqual(math.fmin(NINF,x),NINF) | ||
withself.subTest("math.fmin(x, NINF)",x=x): | ||
self.assertEqual(math.fmin(x,NINF),NINF) |
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.
withself.subTest("math.fmin(INF, x)",x=x): | |
self.assertEqual(math.fmin(INF,x),x) | |
withself.subTest("math.fmin(x, INF)",x=x): | |
self.assertEqual(math.fmin(x,INF),x) | |
withself.subTest("math.fmin(NINF, x)",x=x): | |
self.assertEqual(math.fmin(NINF,x),NINF) | |
withself.subTest("math.fmin(x, NINF)",x=x): | |
self.assertEqual(math.fmin(x,NINF),NINF) | |
withself.subTest(x=x): | |
self.assertEqual(math.fmin(INF,x),x) | |
self.assertEqual(math.fmin(x,INF),x) | |
self.assertEqual(math.fmin(NINF,x),NINF) | |
self.assertEqual(math.fmin(x,NINF),NINF) |
Uh oh!
There was an error while loading.Please reload this page.
I've added
math.fmin
andmath.fmax
as I think it'd be nice to have the NaN handling as per C99. I didn't make those functions generic or accept any iterable argument.WDYT of this proposal@skirpichev@rhettinger?
math
#135853📚 Documentation preview 📚:https://cpython-previews--135888.org.readthedocs.build/