Make pylab import all configurable #551

Closed
wants to merge 6 commits into
from

Projects

None yet

2 participants

@jenshnielsen
Contributor

The import all option for pylab is not configurable with newapp.
I have now made this configurable in both terminal qtconsole,
however I haven't touched the pylab magic.

@fperez fperez commented on the diff Jul 3, 2011
IPython/core/interactiveshell.py
@@ -2416,7 +2416,7 @@ class InteractiveShell(SingletonConfigurable, Magic):
# Things related to GUI support and pylab
#-------------------------------------------------------------------------
- def enable_pylab(self, gui=None):
+ def enable_pylab(self, gui=None, inport_all=True):
@fperez
fperez Jul 3, 2011 Member

typo, should be import_all

@fperez fperez commented on the diff Jul 3, 2011
IPython/frontend/terminal/ipapp.py
@@ -178,6 +178,11 @@ flags['pylab'] = (
"""Pre-load matplotlib and numpy for interactive use with
the default matplotlib backend."""
)
+flags['no-pylab-import-all'] = (
@fperez
fperez Jul 3, 2011 Member

I don't think we should add a separate flag for this. Flags should be only added (since they are special-case code) for major options that we expect to be very widely used. They are only shorthands, since our config mechanism is such that all options can still be set passing the proper expression or in the config file.

This feature, while useful in the code itself, doesn't quite warrant a dedicated command-line flag.

@fperez
Member
fperez commented Jul 3, 2011

As indicated, the basic idea is fine (in fact we used to have this feature in the prior config setup), but it doesn't warrant a standalone flag.

Finally, it needs a test. The test should be marked to run only if matplotlib is importable, but if so, it should create IPython instances passing them a config, both with the value set to true and false, and checking in both cases that the user_ns namespace in the instance either contains or doesn't contain the matplotlib plot() function. We're really trying to ensure that new code improves our test coverage as we go.

It's too tight for this to make it into 0.11, but since now we hope to make quicker releases with the feedback we'll start collecting, merging this in the next few days after you have a chance to implement these changes should be fine for 0.12.

Thanks!

@jenshnielsen
Contributor

OK. Good point about the test. I will implement that and remove the flags. Maybe the alias should also be removed?
I don't think many users want to customize this every time they start ipython with pylab.

Maybe 6c423a1 should be merged into 0.11. The import_all argument to pylab_activate doesn't do anything right now as far as I can see. It is however not a big impact as it is only relevant if a user implements code that calls pylab_activate directly since ipython otherwise always calls pylab_activate without import_all.

@fperez fperez added a commit that referenced this pull request Jul 3, 2011
@fperez fperez Merge fixes to pylab_import_all functionality.
This only merges part of gh-551, the part that is a simple fix ready
for 0.11.  The rest of that work will need to be somewhat refactored.

Closes gh-551.
cdf65ca
@fperez fperez added a commit that closed this pull request Jul 3, 2011
@fperez fperez Merge fixes to pylab_import_all functionality.
This only merges part of gh-551, the part that is a simple fix ready
for 0.11.  The rest of that work will need to be somewhat refactored.

Closes gh-551.
cdf65ca
@fperez fperez closed this in cdf65ca Jul 3, 2011
@fperez
Member
fperez commented Jul 3, 2011

Yes, do remove the alias too.

I've merged and pushed, actually up to 07fb005. You should probably then rebase off master and do the new part from there, in a separate PR, since the later commits don't really apply much anymore.

Thanks for the code! At least the first part will now be in 0.11.

@mattvonrocketstein mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
@fperez fperez Merge fixes to pylab_import_all functionality.
This only merges part of gh-551, the part that is a simple fix ready
for 0.11.  The rest of that work will need to be somewhat refactored.

Closes gh-551.
5f7e88b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment