From 3af4a2b5d091ee0d5b7b7d4e25a702ee49abf87b Mon Sep 17 00:00:00 2001 From: Philipp Holl Date: Sat, 4 Jan 2025 16:41:23 +0100 Subject: [PATCH] Improved error message for sparse compression --- phiml/math/_sparse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phiml/math/_sparse.py b/phiml/math/_sparse.py index 21bcc71c..2002e1ab 100644 --- a/phiml/math/_sparse.py +++ b/phiml/math/_sparse.py @@ -328,7 +328,7 @@ def compress(self, dims: DimFilter): u_idx_packed = choose_backend(u_idx_packed).numpy(u_idx_packed) idx = np.arange(1, c_idx_packed.shape[-1] + 1) # start indexing at 1 since 0 might get removed scipy_csr = csr_matrix((idx, (c_idx_packed[0], u_idx_packed[0])), shape=(c_dims.volume, u_dims.volume)) - assert c_idx_packed.shape[1] == len(scipy_csr.data), "Failed to create CSR matrix because the CSR matrix contains fewer non-zero values than COO. This can happen when the `x` tensor is too small for the stencil." + assert c_idx_packed.shape[1] == len(scipy_csr.data), f"Failed to create CSR matrix because the CSR matrix contains fewer non-zero values than COO. This can happen when the `x` tensor is too small for the stencil. Indices: {c_idx_packed.shape}, Compressed: {scipy_csr.data.shape}" # --- Construct CompressedSparseMatrix --- entries_dim = instance(values).name perm = None