def laplacian_sketch(X, ell, k, do_normalize_feature, normed, callback, **args):
    fd = FrequentDirection(ell, k)
    D = np.array([np.sum(callback(X, i, **args)) for i in range(len(X))])
    if normed:
        D = np.sqrt(D)
    isolation_mask = (D == 0)
    if do_normalize_feature:
        X[(- isolation_mask)] = normalize(X[(- isolation_mask)], norm='l2', axis=1, copy=False)
        D[:] = 1
    for (i, isolation) in enumerate(isolation_mask):
        A_i = ((- 1) * callback(X, i, **args))
        if normed:
            A_i /= D[i]
            A_i /= D
            A_i[i] = (1 - isolation)
        else:
            A_i[i] = D[i]
        fd.add_sample((- A_i))
    return (fd.get_result().T, D)
def laplacian_sketch(X, ell, k, do_normalize_feature, normed, callback, **args):
    fd = FrequentDirection(ell, k)
    D = np.array([np.sum(callback(X, i, **args)) for i in range(len(X))])
    if normed:
        D = np.sqrt(D)
    isolation_mask = (D == 0)
    if do_normalize_feature:
        X[(- isolation_mask)] = normalize(X[(- isolation_mask)], norm='l2', axis=1, copy=False)
        D[:] = 1
    for (i, isolation) in enumerate(isolation_mask):
        A_i = ((- 1) * callback(X, i, **args))
        if normed:
            A_i /= D[i]
            A_i /= D
            A_i[i] = (1 - isolation)
        else:
            A_i[i] = D[i]
        fd.add_sample((- A_i))
    return (fd.get_result().T, D)