Hello everyone, I've been helping scipy.sparse provide a sparse array interface along-side sparse matrix. With that effort making good progress, we are starting to think about bigger implications.
Now may be a good time to reconsider *what to do with np.matrix*. I think we have three options: 1) Leave np.matrix as is (with the docs discouraging its use) 2) Deprecate and then remove np.matrix 3) Split np.matrix out as a separate library `numpy-matrix` (maybe eventually with spmatrix) (Below, I've listed some arguments for each option from previous mailing list conversations.) I'm planning on writing a NEP to summarize the discussion that follows, before proceeding with any work. I'd appreciate your feedback on the feasibility of the above options, or ideas for other options to consider. Thank you! Dan =============================================== *From previous conversations (links below):* Reasons for *1) leave as is*: - Nothing needs to be done. - Use for np.matrix is declining anyway. - Old code can still use np.matrix without any changes. Reasons for *2) remove np.matrix*: - “The purpose here is to remove np.matrix from numpy so beginners will never see it.“ - Option 3) has little payoff if the “teaching advantages” of np.matrix are largely addressed by `@`. - Slightly less maintenance time after the removal. (But more to remove it.) Reasons for *3) numpy-matrix library*: - Allows/Forces old code to switch once to `npm.matrix` (better than multiple times, worse than never). - Old code can start to switch now… and will still work for any previous numpy version. - Devs still have to maintain the code. - Beginners do not see npm.matrix when starting with numpy. But still available. *Details and summary of history:* *Q*: Why now? *A*: We have made progress with handling np.matrix: - Python 2.7 is no longer supported - @ is now available - Docs now suggest that np.matrix should not be used for new code - Docs are largely free of np.matrix (but not all – subclass examples use np.matrix) - Scipy.sparse supports sparray (spmatrix is still there too) - Array API sets expectations for containers. - We have the history of numpy-financial as a previous split-off library. Previous discussion ideas not yet implemented: (Many others are already implemented) - “The purpose here is to remove np.matrix from numpy so beginners will never see it.“ - Easy for linear algebra, but later hard to extend to powerful ideas of ndarrays. - `@` should make ndarray easy enough for linear algebra. - 3 different semantics for ndarray, matrix, spmatrix. Matrix does evil by existing. - Teaching concerns: `np.matrix` has powerful (readable) notation for matrix mult, pow, and inverse. Most agree that `@` is all that’s needed. The `pow` and `inv` methods are OK. - Idea: Split out np.matrix as a library `numpy-matrix`-> npm.matrix - Make the new library look at numpy version and if old, use np.matrix code. If numpy is new, use npm.matrix code. (Allows people to switch their code while still supporting old numpy. Creates pointers to np.matrix for type checking, etc.) - Remove remaining examples of np.matrix from numpy docs. - `spmatrix` and `np.matrix` are linked. Sometimes `spmatrix` returns `np.matrix`. *Links:* - 2017 mailing list thread <https://mail.python.org/archives/list/numpy-discussion@python.org/thread/5FOUQF6X3SHFZPEO6ZSRHBIEYXIXKD3H/#2WKQEQXBDKGTDCAQYMNUKYJKXL5T532Y> - 2014 mailing list thread <https://mail.python.org/archives/list/numpy-discussion@python.org/thread/FVUVQ7DKSMAUHEPWYJ4TP6YDNYIAVAFE/> - The mailing list in 2008 has multiple threads related to np.matrix. Most posts are not directly related to this question. But if you search the archives for "2008 np.matrix" you will find lots of discussion.
_______________________________________________ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ Member address: arch...@mail-archive.com