-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Description
Is your feature request related to a problem? Please describe.
np.matrix
is deprecated, and is slowly wiped from the public code. New users, I hope, don't learn what np.matrix
is, and that's to the better.
At the same time, sparse matrices have a public interface for creating numpy matrices, which is actually used quite a lot in scipy tests. A new user who is unaware about the existence of numpy matrix type does not have a clear way to anticipate that a matrix is returned, or that it's deprecated. So a possible scenario (from my personal experience, even though I'm not a new user) is that:
- The user calls
spmatrix.todense()
- The following code either emits a deprecation warning for doing matrix operations, or does the usual confusing stuff with matrix vector multiplication.
- The user realizes they should have used
spmatrix.toarray()
, switches to it and carries on.
Describe the solution you'd like
I propose to move towards making .todense
an alias for .toarray
through a deprecation cycle. This could be done by:
- Eliminating
.todense
from scipy own codebase - Adding a keyword-only argument
return_array=False
to.todense
and emitting a deprecation warning if it isn't set to True. - Making
return_array=True
a default - Eventually eliminating it and making
.todense
an alias to.toarray
.
Describe alternatives you've considered
Other options are:
- Keeping todense around until numpy removes it.
- Making it an alias right away and hoping nobody will notice 🙃 idk