quantdata.utils.cvxpy#

CVXPY Utilities#

quantdata.utils.cvxpy.patch_cvxpy_sum_shape_from_args()[source]#

Patch CVXPY’s Sum.shape_from_args() to avoid reducing uninitialized memory.

CVXPY 1.8.2 computes the output shape of cp.sum() by calling np.sum(np.empty(shape)). With NumPy 2.4 this can raise a spurious RuntimeWarning: overflow encountered in reduce while the expression is being validated. Replacing np.empty with np.zeros preserves the shape inference while avoiding the warning.

Returns True when the patch is applied and False when it is already active.