Skip to content

fix set_pickradius and set_picker conflict #26682

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fernandaitoda
Copy link

@fernandaitoda fernandaitoda commented Sep 2, 2023

PR summary

Fix conflict with _pickradius "losing" its value when set_picker was used after set_pickradius for 2D Lines.
Set_picker now setting value as described in documentation (float type for _pickradius)

PR

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.

@ksunden
Copy link
Member

ksunden commented Sep 4, 2023

Artist.set_picker explicitly accepts both None and bool inputs.

However, Line2D.set_picker is not documented to accept these types.

My instinct is to be in favor of supporting them, as they are supported by the superclass, however, I think that we should also update the docstring (and type hints, for that matter).

@fernandaitoda
Copy link
Author

should I update this in this PR? Or maybe start a feature type issue with this?

@ksunden
Copy link
Member

ksunden commented Oct 6, 2023

I would lean toward it being done together, but yeah, some care to be taken in making it behave as expected (with some weight towards existing behavior, at least for the case of float input)

Also consider integer input (e.g. 5 in the original report), isinstance(5, float) is false...

But further beware of isinstance(True, int), which is true.

We may have to explicitly handle the None/boolean cases here instead.

@fernandaitoda
Copy link
Author

actually, when I set a integer value, isinstance(x, float) returns true, so it fixes the original report (I tested it). I don't know exactly why this happens but I found some people trying to check if a input were int or float and isinstance wasn't working for them.
I could do something like:

if float(i).is_integer():
        // int values
    else:
        // float values

but I don't know if it's necessary. What do you think?

@ksunden
Copy link
Member

ksunden commented Oct 15, 2023

isinstance(3, float) certainly returns False, so not sure what you mean?

certainly you can pass the otherwise equivalent 3.0 which will return True, but it is possible to pass an int which does not pass the isinstance check. and also it is certain that if we want special handling for bools we have to be careful of isinstance checks for ints still too.

It is not the case that integers need to be handled differently than floats, other than that bools count as integers.

@fernandaitoda
Copy link
Author

hello, I'm having a problem with matplotlib installation in my ve, i think it's a problem with my operational system and I'll have to format my computer, but I'm waiting till the end of semester for it. To get this PR accepted I should change this details you mentioned, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for author
Development

Successfully merging this pull request may close these issues.

[Bug]: <artist>.set_picker(True) destroys value of <artist>.pickradius(5)
3 participants