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

Make import checks more explicit in %whos #910

Merged
merged 2 commits into from Oct 25, 2011
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 10 additions & 14 deletions IPython/core/magic.py
Expand Up @@ -861,19 +861,15 @@ def magic_whos(self, parameter_s=''):
# for these types, show len() instead of data:
seq_types = ['dict', 'list', 'tuple']

# for numpy/Numeric arrays, display summary info
try:
import numpy
except ImportError:
ndarray_type = None
else:
ndarray_type = numpy.ndarray.__name__
try:
import Numeric
except ImportError:
array_type = None
else:
array_type = Numeric.ArrayType.__name__
# for numpy arrays, display summary info
ndarray_type = None
if 'numpy' in sys.modules:
try:
from numpy import ndarray
except ImportError:
pass
else:
ndarray_type = ndarray.__name__

# Find all variable names and types so we can figure out column sizes
def get_vars(i):
Expand Down Expand Up @@ -918,7 +914,7 @@ def type_name(v):
print vformat.format(vname, vtype, varwidth=varwidth, typewidth=typewidth),
if vtype in seq_types:
print "n="+str(len(var))
elif vtype in [array_type,ndarray_type]:
elif vtype == ndarray_type:
vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
if vtype==ndarray_type:
# numpy
Expand Down