[IPython-dev] Small config puzzle

MinRK benjaminrk@gmail....
Sun Jun 3 14:00:30 CDT 2012


On Sat, Jun 2, 2012 at 8:18 PM, Fernando Perez <fperez.net@gmail.com> wrote:

> Howdy,
>
> (this is likely for Min, but perhaps somebody else knows) I'm kind of
> stumped trying to figure out why this works fine in my config file:
>
> c.InlineBackend.figure_format = 'png'  (or 'svg')
>
> but I can't seem to make this work:
>
> c.InlineBackend.rc['savefig.dpi'] = 96
>
> In fact, I get a traceback:
>
> [IPKernelApp] Exception while loading config file
> /home/fperez/.ipython/profile_default/ipython_notebook_config.py
> Traceback (most recent call last):
>  File
> "/home/fperez/usr/lib/python2.7/site-packages/IPython/config/application.py",
> line 447, in load_config_file
>    config = loader.load_config()
>  File
> "/home/fperez/usr/lib/python2.7/site-packages/IPython/config/loader.py",
> line 269, in load_config
>    self._read_file_as_dict()
>  File
> "/home/fperez/usr/lib/python2.7/site-packages/IPython/config/loader.py",
> line 322, in _read_file_as_dict
>    py3compat.execfile(conf_filename, namespace)
>  File
> "/home/fperez/usr/lib/python2.7/site-packages/IPython/utils/py3compat.py",
> line 178, in execfile
>    __builtin__.execfile(filename, *where)
>  File "/home/fperez/.ipython/profile_default/ipython_notebook_config.py",
> line 7, in <module>
>    c.InlineBackend.rc['savefig.dpi'] = 96
>  File
> "/home/fperez/usr/lib/python2.7/site-packages/IPython/config/loader.py",
> line 167, in __getattr__
>    raise AttributeError(e)
> AttributeError: 'rc'
>
>
> If I make the same change inside the backend_inline file in IPython
> itself it does have an effect, but not in the config file, and I'm
> curious why...  The rc field is a traitlet Dict.
>

The Config file has no idea that rc is a dict (or that rc is an option at
all).

The only thing you can do in config files is assignment:

c.InlineBackend.rc = {'savefig.dpi': 96}

Traitlets are not involved at all in the config files or the construction
of the config object, they determine how the config object (after it is
constructed by config files and command-line opts) is interpreted.

-MinRK


>
> Puzzled...  Before I dig into the traitlets machinery to track this
> down, I figured I'd ask...
>
> f
> _______________________________________________
> IPython-dev mailing list
> IPython-dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-dev/attachments/20120603/74f46a60/attachment.html 


More information about the IPython-dev mailing list