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
%config magic #923
%config magic #923
Conversation
Moving discussion from #903 to here (PR), pinging @fperez and @ellisonbg to keep conversation updates linked up. I've renamed InlineBackendConfig -> InlineBackend (with warning on old name, for any of those still lingering on it). Here's a quick question: Should we switch the inline figure default back to svg from png? PNG is the default, because it's a good deal sharper, and for figure snobs it does look better than SVG. However, it is less capable, in that the SVG+XHTML export will lack figures in the default state (see #735). Since it's easy to change the figure format, maybe we should change the default to the more capable one, and let the nicer-looking format be configurable? A possible issue would be that the svg dpi is tuned such that svg and png figures are the same size in the QtConsole, but I find that they are not the same in a browser using the notebook, and the png size is more sensible. It is also true that png is just a much more portable and reliable (if not editable) format. |
I updated some docs, to cover using the %config magic to configure the inline backend, and moved the completer configurables to the completer class, where they belong. |
@fperez will probably have thoughts on what image format should be default. I am fine moving to png and it does look nicer in many cases. Also, having it as the default will bring png bugs in matplotlib to light more readily. There may be some browser tuning we can/should do to make the figure sizes of png/svg the same. |
@ellisonbg - I should clarify. The default is png, because it looks better. I'm wondering if we should change it to svg because some functionality (xhtml export) is unavailable with the default. |
On Tue, Oct 25, 2011 at 2:14 PM, Min RK
We switched from svg to png a while back in deference to the Browsers tend to have much more robust svg support, so I could see |
@minrk: oops, that was a brain typo, I do realize the default in png. I am fine moving to svg given the support in browsers is much better than the qt console. |
@minrk, note that I'm getting a failure in the test suite when I merge this onto master:
Do you see it too? If not, we can try to debug it together on my box... Problem seen on python 2.6, ubuntu 10.10, 64 bit. |
ps - I think if you want to pass flags in a 2.6-compatible manner to a regexp, you must compile it and then use the 2.6:
2.7:
|
good catch, I didn't realize it had changed. I'll compile&call. |
regex is now compiled, should work on 2.6. |
Heads-up @minrk: this one popped a conflict after I just merged the read-only branch... Can you give it a quick rebase? I was about to work on it and saw the conflicts... |
This method should be used whenever updating the config of an object. It is useful for all configurables, not just Applications.
include deprecation warning on old name
it is a dict of instances, which are not allowed in config
also cleaned up %config and %pylab docstrings to be a little more sphinx-autogen friendly.
* InteractiveShell.readline_omit__names -> IPCompleter.omit__names * InteractiveShell.readline_merge_completions -> IPCompleter.merge_completions add test for IPCompleter.omit__names, which also covers IPCompleter as a configurable. update %config doctest to match, and replace Completer with IPCompleter in TerminalIPythonApp.classes
rebased - tiny conflict with PR #921. |
Looks good, ran lots of tests on 2.6 and 2.7, via screen and normal logins. After some initial weird glitching, that went away with a pyc cleanout, all looks good now so I think it's good to merge. I'm going to leave the image default discussion to happen separately so we don't hold this PR forever, made #944 for that. Merging now, thanks for the great work! This wil be very useful. Final comment: adding mention of |
New %config magic to interactively manipulate all configurables. This allows users to type `%config Foo.bar = 5` to control any IPython configurable. The Magic class keeps a list of configurables which will be updated by the change, so any objects that should be accessible to this magic should be appended to `shell.configurables`. I started with everything I saw as configurable in InteractiveShell. ## Usage Use just `%config` to see what classes are available, and `%config Class` to get the trait info for that class. When setting values via` %config Class.trait = value` It is evaluated with user_ns in globals, so you can do arbitrary things like: ```python In [4]: default = 'png' In [5]: %config InlineBackendConfig.figure_format = raw_input('what figure format should we use? ') or default ``` ## Note This magic reveals just how much we *don't* use traits/config properly. Almost everything is attached to the InteractiveShell object, and has an effect exactly once during an `init_foo()` method, rather than allowing config propagation via `_trait_changed()` methods. For instance, IPCompleter has an `omit__names` attribute, but the configurable is `InteractiveShell.readline_omit__names`, which is clearly wrong. We've done a good job with config in *new* code, but I think existing code needs a pretty hefty pass to get configurables attached to the right objects, and getting logic like `%colors` into `shell._colors_changed`. Closes #903
New %config magic to interactively manipulate all configurables. This allows users to type `%config Foo.bar = 5` to control any IPython configurable. The Magic class keeps a list of configurables which will be updated by the change, so any objects that should be accessible to this magic should be appended to `shell.configurables`. I started with everything I saw as configurable in InteractiveShell. ## Usage Use just `%config` to see what classes are available, and `%config Class` to get the trait info for that class. When setting values via` %config Class.trait = value` It is evaluated with user_ns in globals, so you can do arbitrary things like: ```python In [4]: default = 'png' In [5]: %config InlineBackendConfig.figure_format = raw_input('what figure format should we use? ') or default ``` ## Note This magic reveals just how much we *don't* use traits/config properly. Almost everything is attached to the InteractiveShell object, and has an effect exactly once during an `init_foo()` method, rather than allowing config propagation via `_trait_changed()` methods. For instance, IPCompleter has an `omit__names` attribute, but the configurable is `InteractiveShell.readline_omit__names`, which is clearly wrong. We've done a good job with config in *new* code, but I think existing code needs a pretty hefty pass to get configurables attached to the right objects, and getting logic like `%colors` into `shell._colors_changed`. Closes ipython#903
And InlineBackaedConfig was renamed in 0.12 (2011): `ipython/ipython#923 So we can likely remove the warning.
And InlineBackaedConfig was renamed in 0.12 (2011): `ipython/ipython#923 So we can likely remove the warning.
should close #903
Adds %config magic, which allows
%config Foo.bar = 5
configuration of IPython configurables.The Magic class keeps a list of configurables which will be updated by the change, so any objects that should be accessible to this magic should be appended to
shell.configurables
. I started with everything I saw as configurable in InteractiveShell.Usage
Use just
%config
to see what classes are available, and%config Class
to get the trait info for that class.When setting values via
%config Class.trait = value
It is evaluated with user_ns in globals, so you can do arbitrary things like:Of course, this magic reveals just how much we don't use traits/config properly. Almost everything is attached to the InteractiveShell object, and has an effect exactly once during an
init_foo()
method, rather than allowing config propagation via_trait_changed()
methods.For instance, IPCompleter has an
omit__names
attribute, but the configurable isInteractiveShell.readline_omit__names
, which is clearly wrong.We've done a good job with config in new code, but I think existing code needs a pretty hefty pass to get configurables attached to the right objects, and getting logic like
%colors
intoshell._colors_changed
.