Make import checks more explicit in %whos #910

Merged
merged 2 commits into from Oct 25, 2011

Conversation

Projects
None yet
3 participants
Owner

minrk commented Oct 20, 2011

Since PyPy has a fake numpy, checking for 'import numpy' is insufficient

only check if numpy/numeric in use, to prevent unnecessary imports

%precision has a similar issue, but I'm actually inclined to let it raise (it doesn't crash, or anything, just shows that numpy is not really numpy). %whos is more important, and was entirely broken on PyPy.

closes #904

@minrk minrk Make import checks more explicit in %whos
Since PyPy has a fake numpy, checking for 'numpy' is insufficient

only check if numpy/numeric in use, to prevent unnecessary imports

closes gh-904
8719351
Owner

takluyver commented Oct 20, 2011

Looks sensible. Do we actually still need to check for numeric? It's no longer even in Ubuntu/Debian repos, and the last binary installer is for Python 2.4.

Owner

minrk commented Oct 20, 2011

lol, good point. I think it's perfectly fine to drop support for pretty-printed Numeric arrays in %whos.

Owner

minrk commented Oct 20, 2011

Numeric removed

@takluyver takluyver commented on an outdated diff Oct 20, 2011

IPython/core/magic.py
@@ -918,7 +914,7 @@ Currently the magic system has the following functions:\n"""
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 in [ndarray_type]:
@takluyver

takluyver Oct 20, 2011

Owner

This doesn't really need the in test now.

Owner

takluyver commented Oct 20, 2011

Other than that, it looks fine (I assume you've run it on PyPy)

Owner

minrk commented Oct 20, 2011

comment addressed.

And yes, I have run it on pypy, and also in CPython with a dummy numpy.py that prevents numpy from making any sense.

Owner

fperez commented Oct 21, 2011

+1 from me. Guys, I'm really offline starting tomorrow, so go ahead without me on this one...

minrk merged commit 4c90e86 into ipython:master Oct 25, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment