scipy.io.hb_read¶
- scipy.io.hb_read(path_or_open_file)[源代码]¶
读取HB格式文件。
- 参数
- path_or_open_file类似路径或类似文件
如果是类似文件的对象,则按原样使用。否则,在阅读之前将其打开。
- 退货
- datascipy.parse.csc_Matrix实例
以稀疏矩阵形式从HB文件读取的数据。
注意事项
目前还不支持完全的哈威尔-波音格式。支持的功能包括:
汇编的非对称实数矩阵
指针/索引的整数
浮点值的指数格式和整数格式
示例
我们可以读写Harwell-Boeing格式的文件:
>>> from scipy.io.harwell_boeing import hb_read, hb_write >>> from scipy.sparse import csr_matrix, eye >>> data = csr_matrix(eye(3)) # create a sparse matrix >>> hb_write("data.hb", data) # write a hb file >>> print(hb_read("data.hb")) # read a hb file (0, 0) 1.0 (1, 1) 1.0 (2, 2) 1.0