-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Update round fix #19260
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
Update round fix #19260
Conversation
On webpage `int(pct/100.*np.sum(allvals))` cause a wrong round and absolute number representation. Here `int(round(foo))` make a not needed `int(foo)` conversion. Remove the `int(foo)`.
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.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a while, please feel free to ping @matplotlib/developers
or anyone who has commented on the PR. 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.
I can understand if it's not needed, but what do you mean by wrong? Can you give an example? |
Yes. Now the example on the official page use scores = [116, 133, 18, 19, 4, 2]
def perceptual_absolute(pct, allvals):
absolute = int(pct/100.*np.sum(allvals))
return '{:.2f}%\n({:d})'.format(pct, absolute)
plt.pie(scores.values(), explode=explode,
autopct=lambda pct: perceptual_absolute(pct, list(scores.values())),
pctdistance=1.1, labeldistance=1.2, startangle=0)
The actual code here in master (maybe not deployed yet) use |
For consistency sake with the rest of our examples, it should probably just be |
In this case may be necessary to do |
Edit: woops I didn't read this line from late in the PR:
|
Yeah, fair enough - I didn't realize that |
Interesting point:
All print "56".
All print "-". The conversion is forced before the string replacement. I have edit to use |
PR Summary
On webpage
int(pct/100.*np.sum(allvals))
cause a wrong round and absolute number representation.Here
int(round(foo))
make a not neededint(foo)
conversion.Remove the
int(foo)
.PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).