Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
picnixz wants to merge5 commits intopython:main
base:main
Choose a base branch
Loading
frompicnixz:feat/math/fmin-fmax-135853

Conversation

picnixz
Copy link
Member

@picnixzpicnixz commentedJun 24, 2025
edited
Loading

I've addedmath.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?


📚 Documentation preview 📚:https://cpython-previews--135888.org.readthedocs.build/

@picnixzpicnixz changed the titlegh-135853: addmath.fmax andmath.fmingh-135853: addmath.fmax andmath.fmin [PoC]Jun 24, 2025
@picnixzpicnixzforce-pushed thefeat/math/fmin-fmax-135853 branch from0831229 toafb0a91CompareJune 24, 2025 14:30
@picnixzpicnixz changed the titlegh-135853: addmath.fmax andmath.fmin [PoC]gh-135853: addmath.fmax andmath.fminJun 24, 2025
@picnixzpicnixz marked this pull request as ready for reviewJune 24, 2025 15:10
@picnixzpicnixz requested a review fromskirpichevJune 24, 2025 15:10
@picnixzpicnixz requested a review fromrhettingerJune 24, 2025 15:10
Comment on lines +648 to +656
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)
Copy link
Member

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():

Suggested change
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
Copy link
Member

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?

Copy link
Contributor

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.

Comment on lines +694 to +702
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
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)

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@vstinnervstinnervstinner left review comments

@skirpichevskirpichevAwaiting requested review from skirpichev

@rhettingerrhettingerAwaiting requested review from rhettinger

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@picnixz@vstinner@skirpichev

[8]ページ先頭

©2009-2025 Movatter.jp