Skip to content

Handled non finite values in ax.pie - issue #29860 #29873

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 4 commits into from
Apr 24, 2025

Conversation

AdarshDec
Copy link
Contributor

@AdarshDec AdarshDec commented Apr 6, 2025

Closes #29860 issue
Changes makes sure that user gets proper value error message when data contains non finite values and passed into function pie() in lib/matplotlib/axes/_axes.py. Added the condition to check data for any infinite or Nan value, and if encountered one of these, we raise a value error with 'Wedges sizes must be finite numbers'. Also added test_pie_non_finite_values() in tests/test_axes.py for testing the added functionality.

PR summary

PR checklist

@oscargus
Copy link
Member

oscargus commented Apr 6, 2025

Thanks for your contribution! It seems like you have accidentally added empty lines with spaces and also removed the definition of sx. Other than that, the change and the test seems fine to me.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@rcomer rcomer moved this to Waiting for author in First Time Contributors Apr 7, 2025
@AdarshDec
Copy link
Contributor Author

Thanks for your contribution! It seems like you have accidentally added empty lines with spaces and also removed the definition of sx. Other than that, the change and the test seems fine to me.

Hey, thanks for the review.! Do you want me to update the code according to the suggestions and submit a new PR?

@QuLogic
Copy link
Member

QuLogic commented Apr 10, 2025

There's no need for a new PR; you should update this one with the corrections.

@tacaswell
Copy link
Member

The fix + test look good! Can you please clean up the the whitespace/linting issues?

@AdarshDec
Copy link
Contributor Author

The fix + test look good! Can you please clean up the the whitespace/linting issues?

Yeah, sure!

@AdarshDec AdarshDec force-pushed the bugfix/29860-handle-nan-inf branch 3 times, most recently from 7aca539 to 5ddcb77 Compare April 19, 2025 06:38

def test_pie_non_finite_values():
fig, ax = plt.subplots()
df = [5, float('nan'), float('inf')]
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
df = [5, float('nan'), float('inf')]
values = [5, float('nan'), float('inf')]

Optional. df is typically used as variable name for dataframes, so it's slightly misleading here.

Copy link
Member

@dstansby dstansby left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this - it looks like your first PR to Matplotlib, so contratulations on getting it merged!

@dstansby dstansby merged commit 3d34092 into matplotlib:main Apr 24, 2025
40 checks passed
@dstansby dstansby added this to the v3.11.0 milestone Apr 24, 2025
@dstansby dstansby moved this from Waiting for author to Merged in First Time Contributors Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

ax.pie() raises ValueError when input contains NaN
6 participants