Repository: cupy/cupy

Issue:
Introduce cupyx namespace
As discussed in https://github.com/cupy/cupy/pull/846, we introduce `cupyx` namespace to implement features specific to CuPy.

Note that although there are some other CuPy-specific entities like `ElementwiseKernel` under `cupy` namespace, they are kept as is, as it is less likely to conflict with future versions of NumPy.


Discussion:
LGTM, but should we deprecate `cupy.scatter_add` (by making it raise `DeprecationWarning`)?
Also, I think it's better to mention other CuPy-specific identities which reside in `cupy` namespace.
That can be another PR, though.
> LGTM, but should we deprecate cupy.scatter_add (by making it raise DeprecationWarning)?

I agree, fixed the code to emit the warning.

> Also, I think it's better to mention other CuPy-specific identities which reside in cupy namespace.

As CuPy is expected to behave as a drop-in replacement of NumPy, I personally feel that most users are not interested in that list. I'd like to rather prepare the reverse, i.e., what is missing in CuPy (https://github.com/cupy/cupy/issues/685).  Let's discuss this in another issue if needed, anyway.
When will be this PR merged?
Rebased to the latest master.
Please fix test failures.
Fixed doctest.
Chainer test failures should be fixed after merging https://github.com/chainer/chainer/pull/4363.
LGTM!

Resolving patch:
diff --git a/cupyx/scipy/sparse/__init__.py b/cupyx/scipy/sparse/__init__.py
new file mode 100644
--- /dev/null
+++ b/cupyx/scipy/sparse/__init__.py
@@ -0,0 +1,42 @@
+from cupy.sparse.base import issparse  # NOQA
+from cupy.sparse.base import isspmatrix  # NOQA
+from cupy.sparse.base import spmatrix  # NOQA
+from cupy.sparse.coo import coo_matrix  # NOQA
+from cupy.sparse.coo import isspmatrix_coo  # NOQA
+from cupy.sparse.csc import csc_matrix  # NOQA
+from cupy.sparse.csc import isspmatrix_csc  # NOQA
+from cupy.sparse.csr import csr_matrix  # NOQA
+from cupy.sparse.csr import isspmatrix_csr  # NOQA
+from cupy.sparse.dia import dia_matrix  # NOQA
+from cupy.sparse.dia import isspmatrix_dia  # NOQA
+
+from cupy.sparse.construct import eye  # NOQA
+from cupy.sparse.construct import identity  # NOQA
+from cupy.sparse.construct import rand  # NOQA
+from cupy.sparse.construct import random  # NOQA
+from cupy.sparse.construct import spdiags  # NOQA
+
+# TODO(unno): implement bsr_matrix
+# TODO(unno): implement dok_matrix
+# TODO(unno): implement lil_matrix
+
+# TODO(unno): implement kron
+# TODO(unno): implement kronsum
+# TODO(unno): implement diags
+# TODO(unno): implement block_diag
+# TODO(unno): implement tril
+# TODO(unno): implement triu
+# TODO(unno): implement bmat
+# TODO(unno): implement hstack
+# TODO(unno): implement vstack
+
+# TODO(unno): implement save_npz
+# TODO(unno): implement load_npz
+
+# TODO(unno): implement find
+
+# TODO(unno): implement isspmatrix_bsr(x)
+# TODO(unno): implement isspmatrix_lil(x)
+# TODO(unno): implement isspmatrix_dok(x)
+
+from cupyx.scipy.sparse import linalg  # NOQA
diff --git a/cupyx/scipy/sparse/linalg/__init__.py b/cupyx/scipy/sparse/linalg/__init__.py
new file mode 100644
--- /dev/null
+++ b/cupyx/scipy/sparse/linalg/__init__.py
@@ -0,0 +1,5 @@
+# Functions from the following SciPy document
+# https://docs.scipy.org/doc/scipy/reference/sparse.linalg.html
+
+# "NOQA" to suppress flake8 warning
+from cupy.sparse.linalg.solve import lsqr  # NOQA
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -104,6 +104,8 @@
         'cupyx',
         'cupyx.scipy',
         'cupyx.scipy.ndimage',
+        'cupyx.scipy.sparse',
+        'cupyx.scipy.sparse.linalg',
         'cupyx.scipy.special',
     ],
     package_data=package_data,


Test patch: