Skip to content

Commit

Permalink
Always check for invalid format first
Browse files Browse the repository at this point in the history
  • Loading branch information
projekter committed Nov 7, 2024
1 parent 1b81a3c commit 4b7379a
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions sparse_dot_mkl/_sparse_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ def _sparse_dot_vector(
:rtype: np.ndarray
"""

if (
not _is_allowed_sparse_format(mv_a) or
not _is_allowed_sparse_format(mv_b)
):
raise ValueError(
"Only CSR, CSC, and BSR-type sparse matrices are supported"
)

_sanity_check(mv_a, mv_b, allow_vector=True)

if _empty_output_check(mv_a, mv_b):
Expand All @@ -141,14 +149,7 @@ def _sparse_dot_vector(

mv_a, mv_b = _type_check(mv_a, mv_b, cast=cast)

if (
not _is_allowed_sparse_format(mv_a) or
not _is_allowed_sparse_format(mv_b)
):
raise ValueError(
"Only CSR, CSC, and BSR-type sparse matrices are supported"
)
elif _is_dense_vector(mv_b):
if _is_dense_vector(mv_b):
return _sparse_dense_vector_mult(
mv_a,
mv_b,
Expand Down

0 comments on commit 4b7379a

Please sign in to comment.