You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be great to have autocompletion on rcParams (or settings) in IPython, so you could do
settings["fon<TAB>"]
and get a list of all keys containing the string "fon".
This would be another tool to get people modifying settings.
Currently there is no completion on dictionary keys in IPython -- I am hoping to implement this this week.
However, a nicer solution, in my opinion, is attribute access, so you could do e.g.
settings.xtick.color = 'b'
This is easy to implement by hand. But it turns out that it is already implemented in IPython! Even if in a slightly obscure (but super-general so nothing done by hand) way:
from matplotlib import rcParams
from IPython.config import Config
settings = Config(rcParams)
You can now automatically use the settings.xtick.color syntax and completion!:
settings.xtic<TAB>
gives a list of all the settings starting with xtic. (See below for more completion magic).
However, there is a problem with the names of the rcParams keys using . as a separator, namely that doing
settings.xtick.<TAB>
no longer completes anything. This is because it is treating settings.xtick as a subdictionary or subclass.
There are 2 possible solutions:
Change the names of the settings keys, e.g. to xtick_minor_pad. Yuck.
An excellent solution -- not just for this autocompletion problem -- is the following:
Really turn the sequence of names including .s in the string in the attribute-access pattern into real sub-dictionaries of rcParams.
Of course, this makes the dictionary key syntax horrible, but there would be no longer be any need for it -- we would just switch over wholesale to the . attribute syntax.
Of course, this breaks some backward compatibility, but it gives a much more logical structure to rcParams as a whole.
[And, thinking about it, it should be possible to rewrite the dictionary access functions so that the old key accesses still work!]
Of course, the magic going on in the IPython.config module is easily extractable straight in to rcParams, in case somebody is worried that this depends on IPython.
------- [Comments on future IPython command completion possibilities below]
In fact, I have a mod for IPython's command completion which completes any word containing the letters that you type in a certain order. Here is the output for
It includes things that don't start with fon but contain the sequence of characters f, o, n in that order.
An alternative is to just search for the word fon, without splitting up the characters.
I hope to submit an IPython pull request soon. It will be possible to change between these different types of completion mechanism with a standard IPython configuration method.
The text was updated successfully, but these errors were encountered:
I don't think we would want to add anything specific here - autocompletion on dictionaries is very cool, as would autocomplete on properties / getters, but it is my aspiration that that should just fall out from a sensible setup in the first place.
It would be great to have autocompletion on
rcParams
(orsettings
) in IPython, so you could doand get a list of all keys containing the string "fon".
This would be another tool to get people modifying settings.
Currently there is no completion on dictionary keys in IPython -- I am hoping to implement this this week.
However, a nicer solution, in my opinion, is attribute access, so you could do e.g.
This is easy to implement by hand. But it turns out that it is already implemented in IPython! Even if in a slightly obscure (but super-general so nothing done by hand) way:
You can now automatically use the
settings.xtick.color
syntax and completion!:gives a list of all the settings starting with
xtic
. (See below for more completion magic).However, there is a problem with the names of the
rcParams
keys using.
as a separator, namely that doingno longer completes anything. This is because it is treating
settings.xtick
as a subdictionary or subclass.There are 2 possible solutions:
settings
keys, e.g. to xtick_minor_pad. Yuck.Really turn the sequence of names including
.
s in the string in the attribute-access pattern into real sub-dictionaries ofrcParams
.Of course, this makes the dictionary key syntax horrible, but there would be no longer be any need for it -- we would just switch over wholesale to the
.
attribute syntax.Of course, this breaks some backward compatibility, but it gives a much more logical structure to rcParams as a whole.
[And, thinking about it, it should be possible to rewrite the dictionary access functions so that the old key accesses still work!]
Of course, the magic going on in the IPython.config module is easily extractable straight in to rcParams, in case somebody is worried that this depends on IPython.
------- [Comments on future IPython command completion possibilities below]
In fact, I have a mod for IPython's command completion which completes any word containing the letters that you type in a certain order. Here is the output for
It includes things that don't start with
fon
but contain the sequence of charactersf
,o
,n
in that order.An alternative is to just search for the word
fon
, without splitting up the characters.I hope to submit an IPython pull request soon. It will be possible to change between these different types of completion mechanism with a standard IPython configuration method.
The text was updated successfully, but these errors were encountered: