Skip to content
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

Fix use() so that it is possible to reset the rcParam. #1028

Merged
merged 1 commit into from Jul 21, 2012

Conversation

dopplershift
Copy link
Contributor

With this change, the warn argument acts as a way to ignore the warning
and force the rcParam change. This allows switch_backend() to actually
function again.

@WeatherGod
Copy link
Member

you accidentially added a swap file with this commit.

@efiring
Copy link
Member

efiring commented Jul 20, 2012

I strongly oppose this, as explained in my reply to your original email.

@dopplershift
Copy link
Contributor Author

I noticed the .swp commit (no idea how that happened). This is a new set of commits that adds a 'force' parameter to use and uses this in switch_backend().

@efiring
Copy link
Member

efiring commented Jul 20, 2012

Sorry to be fussy, but I really think the reload needs to be moved from switch_backends to use. In use, if the module was already loaded, then set a flag; and at the end of use, if that flag is set, do the reload. Otherwise there is a mismatch between the state of the system and the rcParams.

Am I missing something here?

@dopplershift
Copy link
Contributor Author

I guess not. It seemed like this would have made switch_backend() largely superfluous, but I guess it still has all the pylab setup code.

This is probably yet more clean.

@dopplershift
Copy link
Contributor Author

This seems to be working alright.

One more question: I think now I'd like to add a flag that controls whether switch_backend() closes the old figures. Thoughts?

@efiring
Copy link
Member

efiring commented Jul 20, 2012

Why would you want to do that? What happens if an old window gets redrawn, or something gets plotted to it, after you have made the switch? Why do you want to do all this switching in the first place? It seems like it is opening up a big can of worms, so it needs a compelling use case.

@@ -920,23 +920,37 @@ def use(arg, warn=True):
loaded. In certain black magic use cases, e.g.
:func:`pyplot.switch_backends`, we are doing the reloading necessary to
make the backend switch work (in some cases, e.g. pure image
backends) so one can set warn=False to supporess the warnings.
backends) so one can set warn=False to suppress the warnings.
Copy link
Member

Choose a reason for hiding this comment

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

Docstring still needs work to explain exactly what warn and force do.

@WeatherGod
Copy link
Member

@efiring, you haven't seen the ipython notebooks, have you? This is the driver for it, to be able to switch back and forth between two backends.

@dopplershift
Copy link
Contributor Author

It seems technically possible to continue to run a gui figure in the background while using image figures elsewhere.

I view this as something that is usually a really bad idea, but to have a hook to do it if you claim to know what you are doing. I'd document it as so.

In the same vein of being unsafe, I had started to document the kwargs to use(), but had stopped because I didn't want to encourage anyone to use them. I guess it may be better to be explicit about their danger in a documented fashion.

@dopplershift
Copy link
Contributor Author

it seems that we end up closing down the event loop, so the not-closing feature is better left as a thought experiment.

I'll update the docstrings.

@efiring
Copy link
Member

efiring commented Jul 20, 2012

On 2012/07/20 11:28 AM, Benjamin Root wrote:

@efiring, you haven't seen the ipython notebooks, have you? This is
the driver for it, to be able to switch back and forth between two
backends.

I'm vaguely familiar with it. I think I tried one briefly a while back.
It's still not obvious to me why the notebook application makes it
important to be able to switch backends.

@dopplershift
Copy link
Contributor Author

Switching between the image and GUI backends allows you to be able to work with interactive and inline figures within a single notebook. Without switching backends, you have to choose.

Add an option to use() that allows forcing the configuration change
which also reloads the module as necessary. Fix and slightly refactor
switch_backend() to make use of this functionality.
@WeatherGod
Copy link
Member

I see no other reason to withhold this PR. It does fix a definite bug. There are some other issues, but they probably should be addressed in a different PR.

WeatherGod added a commit that referenced this pull request Jul 21, 2012
Fix use() so that it is possible to reset the rcParam.
@WeatherGod WeatherGod merged commit 60d869c into matplotlib:master Jul 21, 2012
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.

None yet

3 participants