from module import * is generally considered bad form in application code, for the reason you're seeing - it makes it very hard to tell which modules functions are coming from, especially if you do this for more than one module
Right now, you have:
from numpy import *
# from scipy.sparse import *
a = kron(Mat,ones((8,1)))
b = a.flatten()
Uncommenting the second line might affect where ones and kron comes from. But unless you look up whether sparse redefines these, you won't know. Better to write it like this:
import numpy as np
from scipy import sparse
a = np.kron(Mat, np.ones((8,1)))
b = a.flatten()
And then you can swap np for sparse where you want to use the sparse version, and the reader will immediately know which one you're using. And you'll get an error if you try to use a sparse version when in fact there isn't one.
from scipy import sparseandsparse.kron ...ornp.kron ...so there isn't confusion. You can also printato tell whether its dense or sparse. - hpauljkronexist both in packagescipy.sparse' andnumpy? - B.Du