Skip to content

Commit 6d6887a

Browse files
authored
Merge pull request #618 from mrava87/bug-restrictioncupy
bug: fix problem in Restriction when passing iava as cupy array
2 parents bcd4da2 + 71dc191 commit 6d6887a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pylops/basicoperators/restriction.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
get_array_module,
1313
get_normalize_axis_index,
1414
inplace_set,
15-
to_cupy_conditional,
15+
to_numpy,
1616
)
1717
from pylops.utils.typing import DTypeLike, InputDimsLike, IntNDArray, NDArray
1818

@@ -146,7 +146,7 @@ def __init__(
146146
# explicitly create a list of indices in the n-dimensional
147147
# model space which will be used in _rmatvec to place the input
148148
if ncp != np:
149-
self.iavamask = _compute_iavamask(self.dims, axis, iava, ncp)
149+
self.iavamask = _compute_iavamask(self.dims, axis, to_numpy(iava), ncp)
150150
self.inplace = inplace
151151
self.axis = axis
152152
self.iavareshape = iavareshape
@@ -173,7 +173,6 @@ def _rmatvec(self, x: NDArray) -> NDArray:
173173
)
174174
else:
175175
if not hasattr(self, "iavamask"):
176-
self.iava = to_cupy_conditional(x, self.iava)
177176
self.iavamask = _compute_iavamask(self.dims, self.axis, self.iava, ncp)
178177
y = ncp.zeros(int(self.shape[-1]), dtype=self.dtype)
179178
y = inplace_set(x.ravel(), y, self.iavamask)

0 commit comments

Comments
 (0)