From 097d4d91cc33e483bfdb491dff3a545aeb20dcea Mon Sep 17 00:00:00 2001 From: ZedongPeng Date: Tue, 20 May 2025 10:21:55 -0400 Subject: [PATCH] fix: remove the support of bcoo.fromdense setting nse=shape[0]*shape[1] will make the matrix fully dense and mpax very slow --- mpax/mp_io.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mpax/mp_io.py b/mpax/mp_io.py index 7c820cb..fdf7747 100644 --- a/mpax/mp_io.py +++ b/mpax/mp_io.py @@ -183,11 +183,7 @@ def transform_to_bcoo(input_matrix): ValueError The input matrix format is not supported. """ - if isinstance(input_matrix, (jnp.ndarray, np.ndarray)): - bcoo_matrix = BCOO.fromdense( - input_matrix, nse=input_matrix.shape[0] * input_matrix.shape[1] - ) - elif isinstance(input_matrix, BCSR): + if isinstance(input_matrix, BCSR): bcoo_matrix = input_matrix.to_bcoo() elif isinstance(input_matrix, (sparray, spmatrix)): bcoo_matrix = BCOO.from_scipy_sparse(input_matrix) @@ -196,8 +192,8 @@ def transform_to_bcoo(input_matrix): else: raise ValueError( "Unsupported matrix format. " - "The constraint matrix must be one of the following types: " - "jnp.ndarray, numpy.ndarray, BCOO, or BCSR." + "The sparse constraint matrix must be one of the following types: " + "scipy.sparse.sparray, scipy.sparse.spmatrix, BCOO, or BCSR." ) return bcoo_matrix