[Numpy-discussion] npy/npz file extensions in save/savez

Ralf Gommers ralf.gommers at googlemail.com
Sat Jun 27 15:41:22 EDT 2009


Hi,

The .npy/.npz extensions are just suggestions and can be replaced with
something application-specific according to the NEP (see "Conventions" in
http://svn.scipy.org/svn/numpy/trunk/doc/neps/npy-format.txt). However the
code in save/savez does not seem to allow this. Pass in 'filename.ext' and
out comes 'filename.ext.npy'. The relevant code in `save` is:

if isinstance(file, basestring):
        if not file.endswith('.npy'):
            file = file + '.npy'

Replacing the second line with:
  if not os.path.splitext(file)[1]:
would fix it I think. Same for `savez`. `load` does the correct thing, it
only cares about the magic string and not the extension.

Should save/savez allow other extensions? If so, should I open a ticket and
attach this as a patch?

Cheers,
Ralf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20090627/546b4162/attachment.html>


More information about the NumPy-Discussion mailing list