[Python-modules-team] Bug#564774: python-numpy: savez() does _not_ compress

Michael Hanke michael.hanke at gmail.com
Mon Jan 11 21:15:58 UTC 2010


Package: python-numpy
Version: 1:1.3.0-3
Severity: normal

Hi,

the docs of the savez() function say:

| Save several arrays into a single, compressed file with extension ".npz"

However, that is not the case. Here is a short dump of an IPython
session to show it:

>>> import numpy as np
>>> np.savez('test.npz', N.ones((10000, 1000)))
>>> ll -h *.npz
-rw-r--r-- 1 michael michael 77M 2010-01-11 15:52 test.npz
>>> !gzip test.npz
>>> ll -h test*.gz
-rw-r--r-- 1 michael michael 114K 2010-01-11 15:52 test.npz.gz
                             ^^^^


If I want to load my "hand-compressed", renamed to have .npz extension,
file I get this (2 attempts):

In [1]: N.load('test.npz')
---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)

/tmp/<ipython console> in <module>()

/usr/lib/python2.5/site-packages/numpy/lib/io.pyc in load(file, mmap_mode)
    199         except:
    200             raise IOError, \
--> 201                 "Failed to interpret file %s as a pickle" % repr(file)
    202 
    203 def save(file, arr):

IOError: Failed to interpret file 'test.npz' as a pickle


In [3]: import gzip

In [4]: N.load(gzip.open('test.npz'))
---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)

/tmp/<ipython console> in <module>()

/usr/lib/python2.5/site-packages/numpy/lib/io.pyc in load(file, mmap_mode)
    188     fid.seek(-N,1) # back-up
    189     if magic.startswith(_ZIP_PREFIX):  # zip-file (assume .npz)
--> 190         return NpzFile(fid)
    191     elif magic == format.MAGIC_PREFIX: # .npy file
    192         if mmap_mode:

/usr/lib/python2.5/site-packages/numpy/lib/io.pyc in __init__(self, fid)
     83         # component of the so-called standard library.
     84         import zipfile
---> 85         _zip = zipfile.ZipFile(fid)
     86         self._files = _zip.namelist()
     87         self.files = []

/usr/lib/python2.5/zipfile.pyc in __init__(self, file, mode, compression, allowZip64)
    344 
    345         if key == 'r':
--> 346             self._GetContents()
    347         elif key == 'w':
    348             pass

/usr/lib/python2.5/zipfile.pyc in _GetContents(self)
    364         is bad."""
    365         try:
--> 366             self._RealGetContents()
    367         except BadZipfile:
    368             if not self._filePassed:

/usr/lib/python2.5/zipfile.pyc in _RealGetContents(self)
    374         """Read in the table of contents for the ZIP file."""
    375         fp = self.fp
--> 376         endrec = _EndRecData(fp)
    377         if not endrec:
    378             raise BadZipfile, "File is not a zip file"

/usr/lib/python2.5/zipfile.pyc in _EndRecData(fpin)
    131     The data is a list of the nine items in the ZIP "End of central dir"
    132     record followed by a tenth item, the file seek offset of this record."""
--> 133     fpin.seek(-22, 2)               # Assume no archive comment.
    134     filesize = fpin.tell() + 22     # Get file size
    135     data = fpin.read()

/usr/lib/python2.5/site-packages/numpy/lib/io.pyc in seek(self, offset, whence)
     36 
     37         if whence not in [0, 1]:
---> 38             raise IOError, "Illegal argument"
     39 
     40         if offset < self.offset:

IOError: Illegal argument




Thanks,

Michael


-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.31-1-686 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages python-numpy depends on:
ii  libatlas3gf-base [liblapack. 3.6.0-24    Automatically Tuned Linear Algebra
ii  libblas3gf [libblas.so.3gf]  1.2-2       Basic Linear Algebra Subroutines 3
ii  libc6                        2.10.2-2    GNU C Library: Shared libraries
ii  libgcc1                      1:4.4.2-3   GCC support library
ii  libgfortran3                 4.4.2-3     Runtime library for GNU Fortran ap
ii  liblapack3gf [liblapack.so.3 3.2.1-2     library of linear algebra routines
ii  python                       2.5.4-2     An interactive high-level object-o
ii  python-central               0.6.14+nmu2 register and build utility for Pyt

python-numpy recommends no packages.

Versions of packages python-numpy suggests:
ii  python-nose                   0.11.1-1   test discovery and running for Pyt
pn  python-numpy-dbg              <none>     (no description available)
pn  python-numpy-doc              <none>     (no description available)

-- no debconf information





More information about the Python-modules-team mailing list