`fmm.mmread(stream)` closes stream (`scipy.io.mmread(stream)` does not)
Closed this issue · 1 comments
eriknw commented
I discovered a small difference between fmm.mmread
and scipy.io.mmread
:
import fast_matrix_market as fmm
import scipy
from io import StringIO
text = """%%MatrixMarket matrix coordinate real general
3 3 4
1 3 1
2 2 2
3 1 3
3 1 4"""
stream = StringIO(text)
A1 = scipy.io.mmread(stream)
stream.seek(0) # works after using scipy.io.mmread
A2 = fmm.mmread(stream)
stream.seek(0) # <-- ValueError: I/O operation on closed file
This isn't particularly important or urgent, but I thought you would like to know differences between fmm.mmread
and scipy.io.mmread
.
alugowski commented
Good find!
The solution was tricky to locate as nothing was explicitly calling a close()
method, and the problem didn't manifest while debugging. Turns out the string-to-bytes converter was based on a class that had an implicit close()
. Fixed :)