Skip to content

Commit

Permalink
Improved error message for sparse compression
Browse files Browse the repository at this point in the history
  • Loading branch information
holl- committed Jan 4, 2025
1 parent f64a612 commit 3af4a2b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion phiml/math/_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3af4a2b

Please sign in to comment.