Use cupy.where instead of argwhere
@@ -123,16 +123,10 @@ class _data_matrix(_base.spmatrix):
def _find_missing_index(ind, n):
positions = cupy.arange(ind.size)
diff = ind != positions
- non_zero = cupy.argwhere(diff).ravel()
-
- if non_zero.size != 0:
- return non_zero[0]
-
- k = ind.size + 1
- if k < n:
- return cupy.asarray(k)
- else:
- return cupy.asarray(-1)
+ return cupy.where(
+ diff.any(),
+ diff.argmax(),
+ cupy.asarray(ind.size if ind.size < n else -1))
class _minmax_mixin(object):
