scipy.io.hb_write

scipy.io.hb_write(path_or_open_file, m, hb_info=None)[源代码]

写入HB格式文件。

参数
path_or_open_file类似路径或类似文件

如果是类似文件的对象,则按原样使用。否则,在写入之前将其打开。

m稀疏矩阵

要写入的稀疏矩阵

hb_infoHBInfo

包含要写入的元数据

退货

注意事项

目前还不支持完全的哈威尔-波音格式。支持的功能包括:

  • 汇编的非对称实数矩阵

  • 指针/索引的整数

  • 浮点值的指数格式和整数格式

示例

我们可以读写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