def scipy2sparse(vec, eps=1e-09):
 vec = vec.tocsr()
 assert (vec.shape[0] == 1)
 return [(int(pos), float(val)) for (pos, val) in zip(vec.indices, vec.data) if (np.abs(val) > eps)]

def scipy2sparse ( vec , eps = 1e-09 ) : vec = vec . tocsr ( ) assert ( vec . shape [ 0 ] == 1 ) return [ ( int ( pos ) , float ( val ) ) for ( pos , val ) in zip ( vec . indices , vec . data ) if ( np . abs ( val ) > eps ) ]
convert a scipy .