scipy.io.
hb_write#
- scipy.io.hb_write(path_or_open_file, m, hb_info=None)[source]#
写入 HB 格式文件。
- 参数:
- path_or_open_file路径型或文件型
如果是一个文件型对象,则按原样使用。否则,在写入前将其打开。
- m稀疏数组或矩阵
要写入的稀疏数组
- hb_infoHBInfo
包含用于写入的元数据
- 返回:
- 无
备注
目前不支持完整的 Harwell-Boeing 格式。支持的特性包括:
汇编的、非对称的、实数矩阵
指针/索引的整数类型
浮点值的指数格式和整数格式
示例
我们可以读取和写入 Harwell-Boeing 格式文件
>>> from scipy.io import hb_read, hb_write >>> from scipy.sparse import csr_array, eye >>> data = csr_array(eye(3)) # create a sparse array >>> hb_write("data.hb", data) # write a hb file >>> print(hb_read("data.hb", spmatrix=False)) # read a hb file <Compressed Sparse Column sparse array of dtype 'float64' with 3 stored elements and shape (3, 3)> Coords Values (0, 0) 1.0 (1, 1) 1.0 (2, 2) 1.0