From cbb459ec04a68c35b050a3ef3e10e16fefcbf099 Mon Sep 17 00:00:00 2001 From: Josh Carmichael Date: Wed, 5 Aug 2026 10:25:23 -0400 Subject: [PATCH 1/2] filter warning triggered by cvxpy --- src/aspire/abinitio/commonline_sdp.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/aspire/abinitio/commonline_sdp.py b/src/aspire/abinitio/commonline_sdp.py index 763ebbf56f..02784ba468 100644 --- a/src/aspire/abinitio/commonline_sdp.py +++ b/src/aspire/abinitio/commonline_sdp.py @@ -1,4 +1,5 @@ import logging +import warnings import cvxpy as cp import numpy as np @@ -142,7 +143,18 @@ def _compute_gram_SDP(self, S, A, b): G = cp.Variable((n, n), symmetric=True) # The operator >> denotes matrix inequality. constraints = [G >> 0] - constraints += [cp.trace(A[i] @ G) == b[i] for i in range(3 * self.n_img)] + + # cvxpy.trace uses uninitialized scratch array to infer shapes. + # This can cause a RuntimeWarning, see cvxpy issue #3235. + # This warnings filter can be removed once cvxpy > 1.9.2 + with warnings.catch_warnings(): + warnings.filterwarnings( + "ignore", + message=r"invalid value encountered in reduce", + category=RuntimeWarning, + ) + constraints += [cp.trace(A[i] @ G) == b[i] for i in range(3 * self.n_img)] + prob = cp.Problem(cp.Minimize(cp.trace(-S @ G)), constraints) prob.solve() From 815b5d8386961c41cef79da13407c5033f3b90b5 Mon Sep 17 00:00:00 2001 From: Josh Carmichael Date: Wed, 5 Aug 2026 11:01:00 -0400 Subject: [PATCH 2/2] oops, left the second trace outside the filter --- src/aspire/abinitio/commonline_sdp.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/aspire/abinitio/commonline_sdp.py b/src/aspire/abinitio/commonline_sdp.py index 02784ba468..25529a4c68 100644 --- a/src/aspire/abinitio/commonline_sdp.py +++ b/src/aspire/abinitio/commonline_sdp.py @@ -154,8 +154,7 @@ def _compute_gram_SDP(self, S, A, b): category=RuntimeWarning, ) constraints += [cp.trace(A[i] @ G) == b[i] for i in range(3 * self.n_img)] - - prob = cp.Problem(cp.Minimize(cp.trace(-S @ G)), constraints) + prob = cp.Problem(cp.Minimize(cp.trace(-S @ G)), constraints) prob.solve() return G.value.astype(self.dtype, copy=False)