Skip to content

Fix various issues from SonarQube #23494

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 10 commits into from
Aug 3, 2022
Merged

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Jul 28, 2022

PR Summary

Mostly removing dead variables and returns, ensuring consistency between subclass method signatures, and a bit of cleanup.

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • [n/a] New features are documented, with examples if plot related.
  • [n/a] New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • [n/a] API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • [n/a] Documentation is sphinx and numpydoc compliant (the docs should build without error).

@@ -309,10 +309,9 @@ def test_add_collection():
# GitHub issue #1490, pull #1497.
plt.figure()
ax = plt.axes()
coll = ax.scatter([0, 1], [0, 1])
ax.add_collection(coll)
Copy link
Member

Choose a reason for hiding this comment

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

This is funny enough looking I'm worried this was intentional to test double adding artists or some such.

Copy link
Member Author

Choose a reason for hiding this comment

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

The comment about what the test does and the name of the test seem to be a bit in disagreement. Not sure if it's intentional, but by the comment, it seems like it shouldn't be there...

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, looking at the original PR and issue, it's definitely about empty collections, and the duplicate add_collection seems to be an error.

Copy link
Member

Choose a reason for hiding this comment

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

🐑

@tacaswell tacaswell added this to the v3.6.0 milestone Aug 2, 2022
@@ -34,11 +34,11 @@
def onpick(event):

if event.artist != line:
return True
Copy link
Member

Choose a reason for hiding this comment

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

This changes the return type and bool value of the return. Do we not actually use this return?

Copy link
Member Author

Choose a reason for hiding this comment

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

No event handlers use the return value; CallbackRegistry does not do anything with it.

if animation.ax.get_renderer_cache():
animation.draw()
start_anim.timer.add_callback(local_draw)
start_anim.timer.add_callback(animation.draw)
Copy link
Member

Choose a reason for hiding this comment

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

This is changing the semantics to call draw() unconditionally. I don't claim to understand why the original code did not draw if there is a renderer_cache, but we should now why it's been there and can now leave it out (@tacaswell you wrote this originally).

Semi-OT: This removes the only usage of Axes.get_renderer_cache, which is undocumented by the way. Do we still need to expose this? If yes, this needs documentation, if no we should deprecate it.

Copy link
Member

Choose a reason for hiding this comment

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

I suspect that this was a hedge to make sure we were actually drawn once before running because the draw method on Animation requires use Axes.draw_artist which in turn requires the Axes to have been drawn once to get a cached render.

However, we have made a lot of progress in pushing the caching of renderers into exactly 1 place and only access them via a function that will fabricate one if needed so I suspect we may no longer need this.

Copy link
Member Author

Choose a reason for hiding this comment

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

See above: #23494 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

See #23202 for removal of the Axes.get_renderer_cache

@tacaswell tacaswell merged commit b5ac96a into matplotlib:main Aug 3, 2022
@QuLogic QuLogic deleted the sonarqube-fixes branch August 3, 2022 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants