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

Simplify callable(self._contains) checks#13057

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

Merged
tacaswell merged 1 commit intomatplotlib:masterfromtwmr:simplifycallable
Feb 23, 2019

Conversation

twmr
Copy link
Contributor

Artist._contains can either be None (not-set) or a callable (see
docstring of Artist.set_contains). Therefore, the
callable(self._contains) checks can be simplified to
bool(self._contains).

PR Summary

I had a look at the traitlets PR (#4762, still has unresolved merge conflicts) and noticed some parts that could be moved to its own PR.

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

Copy link
Member

@timhoffmtimhoffm left a comment

Choose a reason for hiding this comment

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

Not quite sure if the change is worth the effort. But if so, it should be an explicit ˋis not Noneˋ check.

@@ -430,6 +430,8 @@ def contains(artist: Artist, event: MouseEvent) -> bool, dict
implementation of the respective artist, but may provide
additional information.
"""
if not callable(picker):
Copy link
Member

Choose a reason for hiding this comment

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

I think it‘s reasonable to keep this check. And not just fail when trying to call _contains

@twmr
Copy link
ContributorAuthor

I'm also not really sure if it is worth the effort.@rmorshea do you remember why you had to change the_contains checks in#4762?

@timhoffm is it documented somewhere that the explicitif x is not None checks are preferred over theif x checks in matplotlib? I'm aware of the differences but I don't understand why matplotlib prefers the explicitif x is not None checks.

@timhoffm
Copy link
Member

None-check handling is not documented within matplotlib. However, it's generalPEP8.

Artist._contains can either be None (not-set) or a callable (seedocstring of Artist.set_contains). Therefore, thecallable(self._contains) checks can be simplified toself._contains is not None.
@twmr
Copy link
ContributorAuthor

twmr commentedFeb 2, 2019

None-check handling is not documented within matplotlib. However, it's generalPEP8.

Thx.

I've added "is not None" to all self._contains checks.

@timhoffmtimhoffm added this to thev3.1.0 milestoneFeb 14, 2019
@timhoffm
Copy link
Member

This is a small change, bit still to good.self._contains is not None is more what we actually want to check semantically thancallable(self._contains).

@tacaswelltacaswell merged commitfdfe898 intomatplotlib:masterFeb 23, 2019
@tacaswell
Copy link
Member

Thanks@Thisch !

@lumberbot-app
Copy link

Something went wrong ... Please have a look at my logs.

tacaswell added a commit that referenced this pull requestFeb 23, 2019
…057-on-v3.1.xBackport PR#13057 on branch v3.1.x (Simplify callable(self._contains) checks)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v3.1.0
Development

Successfully merging this pull request may close these issues.

4 participants
@twmr@timhoffm@tacaswell@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp