From 42fdd0ffa705e92d4d9591da270f08e832dd4c6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Eertmans?= Date: Tue, 23 Sep 2025 15:34:45 +0200 Subject: [PATCH] fix: `get_shape()` -> `shape` attribute for CSC matrices/arrays Hi! I'm not sure if this is intended, but using `get_shape` only works for [`csc_matrix`](https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csc_matrix.html), but not [`csc_array`](https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csc_array.html), which raises an error when passing a sparse array as input. I encountered this bug when using the CVXPYLayers, and I could not find any issue related to this error (i.e., the fact that `csc_array` doesn't have a `get_shape` method). If you intend to support both `csc_matrix` and `csc_array`, then using `.shape` works like a charm. Otherwise, I think it would be good to add another check before, as `csc_array.to_csc()` returns a `csc_array`, and not a `csc_matrix` as expected by the `if` guard. --- src/ecos/ecos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ecos/ecos.py b/src/ecos/ecos.py index c395b03..581fa93 100644 --- a/src/ecos/ecos.py +++ b/src/ecos/ecos.py @@ -32,7 +32,7 @@ def solve(c,G,h,dims,A=None,b=None, **kwargs): # set the dimensions # note that we forcibly coerce the shape values to Python ints # (C longs) in case of shenanigans with the underlying storage - m,n1 = (0,len(c)) if G is None else map(int, G.get_shape()) + m,n1 = (0,len(c)) if G is None else map(int, G.shape) p,n2 = (0,n1) if A is None else map(int, A.shape) if n1 != n2: