def to_tuple(mx):
    if (not sp.isspmatrix_coo(mx)):
        mx = mx.tocoo()
    coords = np.vstack((mx.row, mx.col)).transpose()
    values = mx.data
    shape = mx.shape
    return (coords, values, shape)
def to_tuple(mx):
    if (not sp.isspmatrix_coo(mx)):
        mx = mx.tocoo()
    coords = np.vstack((mx.row, mx.col)).transpose()
    values = mx.data
    shape = mx.shape
    return (coords, values, shape)