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

Parameter autocomplete is broken for newer versions of IPython #7

Closed
jahuth opened this issue Feb 13, 2019 · 1 comment
Closed

Parameter autocomplete is broken for newer versions of IPython #7

jahuth opened this issue Feb 13, 2019 · 1 comment
Labels

Comments

@jahuth
Copy link
Owner

jahuth commented Feb 13, 2019

Since IPython switched to jedi for autocompletion, they stopped evaluating code in @property methods.

This has the effect that the magic parameter attribute no longer works in these versions:

import convis
retina = convis.retina.Retina()
retina.p.<press tab> # no completion options are shown

while the expected behaviour is that the options for each contained layer bipolar, gang_0_input, etc. are shown as a selection list.

The p attribute can be saved into a variable, in which case the layers can be accessed, but any further exploration needs to be assigned to a variable to be evaluated, which is not the idea behind convenient model exploration.

While jedi is mostly for static code analysis, they make some exceptions for code in an interactive environment. Maybe at some point they will make that exception also for @property evaluations.

IPython can be configured to not use jedi (but I would not want to recommended that).
There are some tricky ways around the issue that I can use from my side, but the most obvious one requires to instantiate all the objects at once, which takes away the advantage of lazy evaluation and adds a large overhead.

The bottom line is that for now, in the current IPython versions autocomplete of .p. is broken. Autocomplete to the layers still remains intact, so you can access the layers directly, but then have to manually decide which attributes are parameters and which have other purposes.
To inspect models in an Jupyter notebook, you can instead get a nice output of the model structure by putting the model as the last line in cell, causing the notebook to display the object or to get the full structure with all parameters you can use convis.describe(model).

Features like .p._all and .p._search still work, but require explicit execution as the last line of an IPython cell. In general, when autocomplete doesn't work, the options will also be visible when the object is printed or displayed in a notebook. If you are ok with making small cells that you execute often, this is a viable workaround.

## first cell
import convis
retina = convis.retina.Retina() 
## second cell
retina.p  <execute cell>
# shows options opl, ...
# edit cell
retina.p.opl._all  <exceute cell>
# shows all parameters

See also

no completions for @property decorated methods in Interpreter mode #1259
No auto-completion for dynamic attributes #997
(closed) Interpreter completions ignore __dir__() method #1027
(closed) Completion broken for objects with custom dir method #10977

@jahuth jahuth added the bug label Feb 13, 2019
@jahuth
Copy link
Owner Author

jahuth commented Aug 13, 2019

This issue is fixed for the newest version of jedi (which provides the autocomplete for IPython).
See issue jedi #1299

Autocomplete features will work again for jedi 0.15.0 and later. To update jedi manually with pip execute:

pip install --upgrade jedi

@jahuth jahuth closed this as completed Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant