Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ENH: for fresh ipythons add completions for keys of collections

  • Loading branch information...
commit 16f73e7314c543ff08a4132a42a8f9ee6f87431b 1 parent 596f4f3
Yaroslav Halchenko yarikoptic authored
Showing with 16 additions and 8 deletions.
  1. +5 −2 mvpa2/suite.py
  2. +11 −6 mvpa2/support/ipython/__init__.py
7 mvpa2/suite.py
View
@@ -229,8 +229,11 @@
__sdebug("ipython goodies")
if externals.exists("running ipython env"):
- from mvpa2.support.ipython import *
- ipy_activate_pymvpa_goodies()
+ try:
+ from mvpa2.support.ipython import *
+ ipy_activate_pymvpa_goodies()
+ except Exception, e:
+ warning("Failed to activate custom IPython completions due to %s" % e)
def suite_stats():
"""Return cruel dict of things which evil suite provides
17 mvpa2/support/ipython/__init__.py
View
@@ -14,11 +14,6 @@
from mvpa2.base import externals, cfg
if externals.exists('running ipython env'):
ipython_version = externals.versions['ipython']
- if ipython_version >= '0.11~':
- # TODO
- pass
- else:
- from IPython.ipapi import get as ipget
if __debug__:
from mvpa2.base import debug
@@ -29,6 +24,8 @@
def _goodies_pre011():
"""Goodies activator for ipython < 0.11
"""
+ from IPython.ipapi import get as ipget
+
try:
if not cfg.getboolean('ipython', 'complete protected', False):
ipget().IP.Completer.omit__names = 2
@@ -43,7 +40,15 @@ def _goodies_pre011():
def _goodies_011():
"""Goodies activator for ipython >= 0.11
"""
- pass # TODO
+ from IPython.utils.generics import complete_object
+
+ from mvpa2.base.collections import Collection
+
+ @complete_object.when_type(Collection)
+ def complete_collection(obj, prev_completions):
+ # Place all the keys into completion for the collection, be it
+ # an .a, .sa, .fa, .ca, or .params
+ return obj.keys() + prev_completions
def ipy_activate_pymvpa_goodies():
"""Activate PyMVPA additions to IPython
Please sign in to comment.
Something went wrong with that request. Please try again.