2

I am using 0.17 version of scipy library on ubuntu 16.04 64-bit system in python v3.5. I am unable to find scipy.sparse.save_npz operation in the library, although it is mentioned in the latest documentation.

On listing the callable methods from scipy.sparse object I am getting the following output:

['SparseEfficiencyWarning',
 'SparseWarning',
 'Tester',
 'bench',
 'block_diag',
 'bmat',
 'bsr_matrix',
 'coo_matrix',
 'cs_graph_components',
 'csc_matrix',
 'csr_matrix',
 'dia_matrix',
 'diags',
 'dok_matrix',
 'eye',
 'find',
 'hstack',
 'identity',
 'issparse',
 'isspmatrix',
 'isspmatrix_bsr',
 'isspmatrix_coo',
 'isspmatrix_csc',
 'isspmatrix_csr',
 'isspmatrix_dia',
 'isspmatrix_dok',
 'isspmatrix_lil',
 'kron',
 'kronsum',
 'lil_matrix',
 'rand',
 'random',
 'spdiags',
 'spmatrix',
 'test',
 'tril',
 'triu',
 'vstack']

The list should have contained save_npz method but it is not there. If the method has been deprecated then please tell me some good alternatives for saving and loading sparse matrices.

sv_jan5
  • 1,543
  • 16
  • 42

1 Answers1

3

Yes, scipy.sparse.save_npz / load_npz are new in version 0.19.0 http://scipy.github.io/devdocs/release.0.19.0.html

ev-br
  • 24,968
  • 9
  • 65
  • 78
  • What is its best alternative in 0.17 version? – sv_jan5 Mar 25 '17 at 09:37
  • 3
    Find and download the relevant file on `github`. It appears to be self contained python, so should work with earlier versions. – hpaulj Mar 25 '17 at 11:58
  • 1
    Similar code has been around for several years: http://stackoverflow.com/questions/8955448/save-load-scipy-sparse-csr-matrix-in-portable-data-format/42101691#42101691. The MATLAB compatible `io.savemat/loadmat` also handles sparse matrices (`csc` format). – hpaulj Mar 25 '17 at 18:07