diff --git a/CHANGELOG.md b/CHANGELOG.md index 108c9b25..b6b9f315 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ All notable changes to this project will be documented in this file. [Documentation](https://cr-sparse.readthedocs.io/en/latest/) -## [0.4.0] - 2023-10-16 +## [0.4.0] - 2023-10-17 [Documentation](https://cr-sparse.readthedocs.io/en/v0.4.0/) diff --git a/src/cr/sparse/_src/cvx/adm/yall1.py b/src/cr/sparse/_src/cvx/adm/yall1.py index acabcf93..f9d70c03 100644 --- a/src/cr/sparse/_src/cvx/adm/yall1.py +++ b/src/cr/sparse/_src/cvx/adm/yall1.py @@ -87,7 +87,7 @@ def finalize(state, b_max, n_times, n_trans, W=None, nonneg=False): n_trans=state.n_trans+n_trans) def solve_bp(A, b, x0, z0, w, nonneg, gamma, tolerance, max_iters): - """ + r""" Solves the problem :math:`\min \| x \|_1 \, \\text{s.t.}\, A x = b` using ADMM This function implements eq 2.29 of the paper. @@ -202,7 +202,7 @@ def cond(state): def solve_l1_l2(A, b, x0, z0, w, nonneg, rho, gamma, tolerance, max_iters): - """ + r""" Solves the problem :math:`\min \| x \|_1 + \\frac{1}{2 \\rho} \| A x - b \|_2^2` using ADMM This function implements eq 2.25 of the paper. @@ -328,7 +328,7 @@ def cond(state): def solve_l1_l2con(A, b, x0, z0, w, nonneg, delta, gamma, tolerance, max_iters): - """ + r""" Solves the problem :math:`\min \| x \|_1 \\text{s.t.} \| A x - b \|_2 \\leq \\delta` using ADMM This function implements eq 2.27 of the paper. diff --git a/src/cr/sparse/_src/cvx/l1ls.py b/src/cr/sparse/_src/cvx/l1ls.py index bf4dbc36..468ea4c4 100644 --- a/src/cr/sparse/_src/cvx/l1ls.py +++ b/src/cr/sparse/_src/cvx/l1ls.py @@ -116,7 +116,7 @@ class State(NamedTuple): def solve_from(A, y, lambda_, x0, u0, tol=1e-3, xi=1e-3, t0=None, max_iters=MAX_ITERS, pcg_max_iters=PCG_MAX_ITERS): - """ + r""" Solves :math:`\min \| A x - b \|_2^2 + \\lambda \| x \|_1` using the Truncated Newton Interior Point Method """ trans = A.trans @@ -234,7 +234,7 @@ def hessian(x): p3 = prb / prs def preconditioner(x): - """Computes the inverse y = M \ x where M is the preconditioner operator""" + r"""Computes the inverse y = M \ x where M is the preconditioner operator""" x1 = x[:n] x2 = x[n:] upper = p1 * x1 - p2 * x2 @@ -371,7 +371,7 @@ def cond(state): def solve(A, y, lambda_, x0=None, u0=None, tol=1e-3, xi=1e-3, t0=None, max_iters=MAX_ITERS, pcg_max_iters=PCG_MAX_ITERS): - """ + r""" Solves :math:`\min \| A x - b \|_2^2 + \\lambda \| x \|_1` using the Truncated Newton Interior Point Method """ m, n = A.shape diff --git a/src/cr/sparse/_src/opt/projectors/basic.py b/src/cr/sparse/_src/opt/projectors/basic.py index bc455620..6f71ed6a 100644 --- a/src/cr/sparse/_src/opt/projectors/basic.py +++ b/src/cr/sparse/_src/opt/projectors/basic.py @@ -161,7 +161,7 @@ def projector(x): y = box_bound(x - beta * a) def proj_conic(): - """Projector function for Lorentz/ice-cream cone {(x,t): \| x \|_2 \leq t} + r"""Projector function for Lorentz/ice-cream cone {(x,t): \| x \|_2 \leq t} """ @jit def proj(x): diff --git a/src/cr/sparse/_src/opt/proximal_ops/lpnorms.py b/src/cr/sparse/_src/opt/proximal_ops/lpnorms.py index 967da798..6246eae7 100644 --- a/src/cr/sparse/_src/opt/proximal_ops/lpnorms.py +++ b/src/cr/sparse/_src/opt/proximal_ops/lpnorms.py @@ -115,7 +115,7 @@ def proximal_op(x, t): return build(func, proximal_op) def prox_l1_ball(q=1.): - """Returns a prox-capable wrapper for the l1-ball :math:`\{ x : \| x \|_1 \leq q \}` indicator + r"""Returns a prox-capable wrapper for the l1-ball :math:`\{ x : \| x \|_1 \leq q \}` indicator Returns: ProxCapable: A prox-capable function diff --git a/src/cr/sparse/_src/pursuit/util.py b/src/cr/sparse/_src/pursuit/util.py index 747dd95d..8448a346 100644 --- a/src/cr/sparse/_src/pursuit/util.py +++ b/src/cr/sparse/_src/pursuit/util.py @@ -28,7 +28,7 @@ def largest_indices(h, K): def gram_chol_update(L, v): - """Incrementally updates the Cholesky factorization :math:`G = L L^T` where :math:`G = \Phi^T \Phi` + r"""Incrementally updates the Cholesky factorization :math:`G = L L^T` where :math:`G = \Phi^T \Phi` """ m, n = L.shape z = jnp.zeros((m, 1)) diff --git a/tests/cluster/test_spectral.py b/tests/cluster/test_spectral.py index 73134f48..33e0af6a 100644 --- a/tests/cluster/test_spectral.py +++ b/tests/cluster/test_spectral.py @@ -57,9 +57,11 @@ def test_spectral6(): affinity = jnp.vstack((az, za)) print(affinity) true_labels = cluster.labels_from_sizes(jnp.array([m, m])) + print("True Labels: ", true_labels) affinity = BCOO.fromdense(affinity) k = 2 - res = spectral.normalized_symmetric_sparse_fast_k_jit(cnb.KEYS[1], affinity, k) + res = spectral.normalized_symmetric_sparse_fast_k_jit(cnb.KEYS[2], affinity, k) pred_labels = res.assignment + print("Predicted Labels: ", pred_labels) error = cluster.clustering_error(true_labels, pred_labels) - assert error.error == 0 + assert_almost_equal(error.error, 0)