[Scipy-tickets] [SciPy] #1627: Fix mmio/fromfile on gzip on Python 3

SciPy Trac scipy-tickets@scipy....
Thu Mar 22 14:51:15 CDT 2012

#1627: Fix mmio/fromfile on gzip on Python 3
 Reporter:  pv        |       Owner:  somebody   
     Type:  defect    |      Status:  new        
 Priority:  normal    |   Milestone:  Unscheduled
Component:  scipy.io  |     Version:  0.10.0     
 Keywords:            |  
 Consider this:
 Python 3.2.2
 >>> from scipy.io import mmread
 >>> mmread('illc1033.mtx.gz')
 Traceback (most recent call last):
 File ".../scipy/io/mmio.py", line 447, in _parse_body
     flat_data = flat_data.reshape(-1,3)
 ValueError: total size of new array must be unchanged
 with ftp://math.nist.gov/pub/MatrixMarket2/Harwell-

 The reason is passing a GzipFile handle to `numpy.fromfile`. On Python 3,
 PyObject_AsFileDescriptor in `fromfile` succeeds on a GzipFile, although
 it should fail (there is no OS level file handle giving the uncompressed
 stream). As a consequence, the `fromfile` call in `mmread` apparently ends
 up reading an compressed data stream, which causes this error.

 This should be worked around in `scipy.io.mmio` until Python 3 (and Numpy)
 are fixed.

Ticket URL: <http://projects.scipy.org/scipy/ticket/1627>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.

More information about the Scipy-tickets mailing list