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
{{ message }}
Repository navigation
Drawing with spectral layout fails because numpy is not imported (migrated from Trac #601) #592
I have the following stack trace:
'''
File ".../networkx-1.5-py2.6.egg/networkx/drawing/nx_pylab.py", line 881, in draw_spectral
draw(G,spectral_layout(G),**kwargs)
File ".../networkx-1.5-py2.6.egg/networkx/drawing/layout.py", line 464, in spectral_layout
pos=_sparse_spectral(A,dim=dim,weighted=weighted)
File ".../networkx-1.5-py2.6.egg/networkx/drawing/layout.py", line 519, in _sparse_spectral
data=np.asarray(A.sum(axis=1).T)
NameError: global name 'np' is not defined
'''
The reason seems to be that numpy is not imported in _sparse_spectral, where as it is imported e.g. in _spectral. The error seems to still exist in the current source. Here the faulty line moved from line 519 to [https://networkx.lanl.gov/trac/browser/networkx/networkx/drawing/layout.py#L494 494]
Even more subtle than that because the eigen_symmetric function has been renamed eigen.eigsh
I'm pushing a patch and some tests to fix this. Thanks for the report!
Activity
networkx-trac commentedon Jul 20, 2012
Comment in Trac by @dschult, 2011-07-21
Even more subtle than that because the eigen_symmetric function has been renamed eigen.eigsh
I'm pushing a patch and some tests to fix this. Thanks for the report!
networkx-trac commentedon Jul 20, 2012
Comment in Trac by Dan Schult <dschult, 2011-07-21
In [8edc325/networkx]:
'''
#!CommitTicketReference repository="networkx" revision="8edc3258a6e3efa2c3a508590a3113ebdbf24d89"
fix sparse matrix spectral layout imports to import numpy
and rename eigen_symmetric as eigen.eigsh
Fixes #601
'''