Skip to content

Commit 7ec6f6e

Browse files
committed
add optional scipy dependency for numpy sparse
1 parent a3f3486 commit 7ec6f6e

3 files changed

Lines changed: 5 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- uses: actions/checkout@v6
3939
- name: "Main Script"
4040
run: |
41-
EXTRA_INSTALL="pytest types-colorama types-Pygments"
41+
EXTRA_INSTALL="pytest types-colorama types-Pygments scipy-stubs"
4242
curl -L -O https://tiker.net/ci-support-v0
4343
. ./ci-support-v0
4444

arraycontext/impl/numpy/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,14 @@ def sparse_matmul(
214214
assert isinstance(x1.elem_col_indices, np.ndarray)
215215
assert isinstance(x1.row_starts, np.ndarray)
216216

217-
# FIXME: Not sure if the scipy dependency is OK or if it should just use
218-
# the call_loopy fallback? Currently getting errors with the loopy version:
219-
# loopy.diagnostic.LoopyError: One of the kernels in the program has
220-
# been preprocessed, cannot modify target now.
221217
from scipy.sparse import csr_matrix
222218
np_matrix = csr_matrix(
223219
(x1.elem_values, x1.elem_col_indices, x1.row_starts),
224220
shape=x1.shape)
225221

226222
def _matmul(ary: ArrayOrScalar) -> ArrayOrScalar:
227223
assert isinstance(ary, np.ndarray)
228-
return np_matrix @ ary
224+
return cast("ArrayOrScalar", cast("object", np_matrix @ ary))
229225

230226
return cast("ArrayOrContainer", rec_map_container(_matmul, x2))
231227

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ pyopencl = [
4646
pytato = [
4747
"pytato>=2021.1",
4848
]
49+
sparse = [
50+
"scipy",
51+
]
4952
test = [
5053
"basedpyright",
5154
"pytest",

0 commit comments

Comments
 (0)