adding default toggled state for toggle tools #6407

Merged
merged 1 commit into from Aug 8, 2016

Conversation

Projects
None yet
6 participants
Member

fariza commented May 11, 2016

So far toggle tools start their life in the untoggled state, most of the time this is what we want but sometimes it is desirable to initialize a ToogleTool in a toggled state without firing the tool_trigger_xxx event

With the changes in this PR, the initial state can be changed by class attribute during Tool definition default_toggle = True or at the moment of adding the tool to the Toolmanager toolmanager.add_tool('Name', ToolCls, toggle=True)

mdboom added the needs_review label May 11, 2016

@fariza fariza and 1 other commented on an outdated diff May 11, 2016

lib/matplotlib/backend_tools.py
@@ -138,6 +138,14 @@ class ToolToggleBase(ToolBase):
Toggleable tool
Every time it is triggered, it switches between enable and disable
+
+ Parameters
+ ----------
+ *args
+ Variable length argument to be used by the Tool
+ **kwargs
@fariza

fariza May 11, 2016

Member

What is the standard to document optional kwargs? like toggled in this particular case?

@tacaswell

tacaswell May 12, 2016

Owner

at least wrap it it double back ticks so that rst does not choke on opened, but not closed emphasis

tacaswell added this to the 2.1 (next point release) milestone May 12, 2016

Owner

tacaswell commented May 12, 2016

The docs are passing which makes me think these are not actually in the docs?

Member

fariza commented May 12, 2016

It is building the docs, I got that from a numpydoc example somewhere and it didn't have quotes around it

Owner

tacaswell commented May 12, 2016

Interesting, I spent some time fighting with things like that breaking the doc build on some day-job projects.....

Member

fariza commented May 12, 2016

Just in case I added the double back tick

Member

fariza commented May 12, 2016

I don't think the fail is related to these changes

Member

fariza commented May 12, 2016

@OceanWolf any thoughts on this?

Member

fariza commented Jun 9, 2016

@OceanWolf this one is the other that needs a little bit of your attention.
But it doesn't affect MEP27,

Contributor

OceanWolf commented Jun 9, 2016

Just gave it a quick look and it looks good to me. Will give it another look later.

When I first started reading I thought you might go down the object overriding class attribute approach, as far as I see both methods work fine.

Member

fariza commented Jun 22, 2016

I rebased to eliminate conflicts and upgraded the example to use the initial toggled state
I transformed the tool from Hide to Show

Member

QuLogic commented Jun 22, 2016

You have some PEP8 errors; AppVeyor failure appears to be unrelated.

@fariza Federico Ariza adding default toggled state for toggle tools
b440068
Member

fariza commented Jun 22, 2016

@QuLogic pep8 erros corrected

Member

fariza commented Aug 2, 2016

ready to merge?

@fariza fariza merged commit 888bf17 into matplotlib:master Aug 8, 2016

1 of 3 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
coverage/coveralls Coverage decreased (-0.009%) to 70.272%
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details

mdboom removed the needs_review label Aug 8, 2016

fariza deleted the fariza:toggletool-initial-state branch Aug 8, 2016

Member

WeatherGod commented Aug 16, 2016

@fariza, I just noticed that this PR was self-merged. I don't want to make a huge deal about it, as these changes are non-controversial and there was a lack of responses to the PR. The matplotlib organization does not enforce a ban on self-merges, but it is highly discouraged. We don't enforce such a ban because there are emergency situations where it is the correct thing to do (getting TravisCI happy again because pyparsing put out a bad release is an example).

What I would suggest you do next time you get a lack of responses to your PR is to ping the PR. If you still don't get responses, then raise the issue on the gitter chat room or on the mailing list. The lack of responses could simply be due to vacation schedules or other things going on.

As for this PR, if I had actually spent time reviewing it at the time (sorry for not doing so), I would have asked for some tests, if it was possible. The coverage went down because of this PR, which is less than ideal. If tests are possible, then could you please create a PR to include them, please?

Member

fariza commented Aug 16, 2016

Sorry for the self merge.

I understand the policy and be sure it won't happen again.

Regarding the tests, at this moment we don't have the infrastructure to
test this kind of things.
What I was planning is to wait for Mep27 to land and stabilize. Then add a
complete "virtual backend" that will allow to test all the tools and
managers. In this case the coverage goes down just because of extra lines
of code but it is not an actual reduction.

Federico

On Aug 16, 2016 5:12 PM, "Benjamin Root" notifications@github.com wrote:

@fariza https://github.com/fariza, I just noticed that this PR was
self-merged. I don't want to make a huge deal about it, as these changes
are non-controversial and there was a lack of responses to the PR. The
matplotlib organization does not enforce a ban on self-merges, but it is
highly discouraged. We don't enforce such a ban because there are emergency
situations where it is the correct thing to do (getting TravisCI happy
again because pyparsing put out a bad release is an example).

What I would suggest you do next time you get a lack of responses to your
PR is to ping the PR. If you still don't get responses, then raise the
issue on the gitter chat room or on the mailing list. The lack of responses
could simply be due to vacation schedules or other things going on.

As for this PR, if I had actually spent time reviewing it at the time
(sorry for not doing so), I would have asked for some tests, if it was
possible. The coverage went down because of this PR, which is less than
ideal. If tests are possible, then could you please create a PR to include
them, please?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#6407 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABa86WZXYz-HkxVxzc6jcj-bLiZtxzhEks5qgifAgaJpZM4Icle9
.

Contributor

OceanWolf commented Aug 17, 2016

@WeatherGod Ahh, so the coveralls relates to how much of the codebase we have covered by unit-tests?

I kind of understood that that policy existed, but do we have a guide somewhere outlining these kinds of things for the less obvious rules/guidelines?

As for fariza's point, yes, unit tests for backends becomes very difficult due to their graphical nature. In MEP27 I added the template classes, so maybe we can do our testing around that?

I had hoped that pgi would solve our testing woes with gtk3, but alas it works well enough for basic testing, but not good enough for production yet (very buggy). Maybe I can take another look at pgi, improve my gdb debugging skills with python to learn where/how it segfaults, and get that up and running ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment