question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: deprecate spmatrix.A

See original GitHub issue

Is your feature request related to a problem? Please describe.

Sparse matrices copy some parts of the interface from np.matrix. In particular, I was surprised to learn that spmatrix.A is an alias to spmatrix.toarray(). This is extremely similar to np.matrix.A, in turn equivalent to np.matrix.view(np.ndarray). However while in the latter case no data conversion happens, sparse matrices require a conversion, which is expensive both in computation and memory costs. As far as I understand, doing costly calculations on attribute access is not a good pattern and therefore should be discouraged.

Describe the solution you’d like

Emit a DeprecationWarning, recommending users to switch to .toarray() and subsequently remove spmatrix.A in a later version.

Describe alternatives you’ve considered

  • Emit a SparseEfficiencyWarning, recommending users to switch to .toarray() to silence the warning and keep spmatrix.A around.
  • Do nothing.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
akhmerovcommented, Oct 9, 2021

I fear that especially to new users the implications may not be clear. However #14822 is a much better way forward, which removes the need for this proposal.

1reaction
tupuicommented, Jul 30, 2021

Thanks for doing this. If you want this topic to move forward, please send an email to the mailing list summarising all the issues you opened around the topic. For API changes and decisions like these we go with the mailing list as explained in our contributing guide.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sparse and Dense Matrix Classes and Methods - R Project
With R version 3.2.0 and newer,. cBind and rBind are deprecated and produce a deprecation warning (via .Deprecated), and your.
Read more >
www.cs.columbia.edu/~CS6861/sis/sis1.3/sis/include...
If this is true for your compiler, remove the * comment delimiters from the ... If you plan to factor a large number...
Read more >
How do I transform a "SciPy sparse matrix" to a "NumPy matrix"?
I am using a python function called "incidence_matrix(G)", which returns the incident matrix of graph. It is from Networkx package. The problem ...
Read more >
Mailman 3 ANN: SciPy 1.8.0 - NumPy-Discussion - python.org
``NumericalInverseHermite`` has been deprecated from `scipy.stats` and moved to ... MAINT: switch to using spmatrix.toarray instead of .todense * `#14499 ...
Read more >
SciPy 1.5.0 Release Notes — SciPy v1.7.1 Manual
A new keyword-only argument plan is added to all FFT functions in this module. ... #11163: Comparisons between scipy spmatrix and can sparse.SparseArray…...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found