lil_matrix construction raises FutureWarning (numpy #12609)
See original GitHub issueDescription
Constructing a scipy.sparse.lil_matrix
in sparsify_rows
raises a Lil Warnin’*
/Users/vl238/miniconda3/envs/gl/lib/python3.7/site-packages/scipy/sparse/lil.py:504: FutureWarning: future versions will not create a writeable array from broadcast_array. Set the writable flag explicitly to avoid this warning.
if not i.flags.writeable or i.dtype not in (np.int32, np.int64):
Dependency chain:
-
call site in
sparsify_rows
: https://github.com/librosa/librosa/blob/master/librosa/util/utils.py#L1087 -
lil_matrix
(linked list sparse matrix) class: https://github.com/scipy/scipy/blob/master/scipy/sparse/lil.py#L23 -
warning point in
scipy.sparse._prepare_index_for_memoryview
: https://github.com/scipy/scipy/blob/master/scipy/sparse/lil.py#L504 -
scipy issue https://github.com/scipy/scipy/issues/10405
-
numpy issue https://github.com/numpy/numpy/pull/2705
NB: there is another use case of lil_matrix
in librosa.segment.recurrence_to_lag
. Not sure if it is affected.
Steps/Code to Reproduce
Found during CR of #934.
Versions
Darwin-18.6.0-x86_64-i386-64bit
Python 3.7.3 (default, Mar 27 2019, 16:54:48)
[Clang 4.0.1 (tags/RELEASE_401/final)]
NumPy 1.17.0
SciPy 1.3.0
librosa 0.7.0
*pun intended: https://www.youtube.com/watch?v=5_Mtgo9WOL0
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
scipy.sparse.lil_matrix — SciPy v1.9.3 Manual
This is a structure for constructing sparse matrices incrementally. Note that inserting a single item can take linear time in the worst case;...
Read more >creating a scipy.lil_matrix using a python generator efficiently
To recap, my question is: What is the most efficient way to create a scipy.sparse matrix from a python generator or numpy single...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It looks like scipy 1.3.1 has fixed this one for us: https://github.com/scipy/scipy/pull/10379
I tried to create a separate conda environment with latest master branches of numpy, scipy, and librosa, in order to see if the warning would disappear. I would guess that it would, in the wake of scipy/scipy#10379. But i did not succeed in installing scipy from source.
I don’t know why this happens.