From 60f43fe6b88bbeca2e15ce66e1b36f16e737487a Mon Sep 17 00:00:00 2001 From: phschiele Date: Sat, 5 Nov 2022 01:28:34 -0700 Subject: [PATCH] disallow float for diamatrix values --- cvxpy/atoms/elementwise/elementwise.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cvxpy/atoms/elementwise/elementwise.py b/cvxpy/atoms/elementwise/elementwise.py index f02164efbe..d59dcc2893 100644 --- a/cvxpy/atoms/elementwise/elementwise.py +++ b/cvxpy/atoms/elementwise/elementwise.py @@ -60,7 +60,7 @@ def elemwise_grad_to_diag(value, rows, cols): """ if not np.isscalar(value): value = value.ravel(order='F') - return sp.dia_matrix((value, [0]), shape=(rows, cols)).tocsc() + return sp.dia_matrix((np.atleast_1d(value), [0]), shape=(rows, cols)).tocsc() @staticmethod def _promote(arg, shape: Tuple[int, ...]):