Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

np.load() fails to read empty archive created by np.savez() #9989

Closed
jzwinck opened this issue Nov 9, 2017 · 3 comments
Closed

np.load() fails to read empty archive created by np.savez() #9989

jzwinck opened this issue Nov 9, 2017 · 3 comments

Comments

@jzwinck
Copy link
Contributor

jzwinck commented Nov 9, 2017

Try this:

np.savez('nothing.npz') # OK
np.load('nothing.npz') # error

Loading fails:

OSError: Failed to interpret file 'nothing.npz' as a pickle

It should succeed (and give you an object with no arrays inside). Likewise for savez_compressed() (which also currently fails).

I'm using NumPy 1.13.1.

@ghost
Copy link

ghost commented Nov 16, 2017

Implementation of _savez (which both savez andsavez_compressed use underneath) makes it possible to create empty archive, which load function cannot unpickle later:

_pickle.UnpicklingError: A load persistent id instruction was encountered,
but no persistent_load function was specified.

Can we add array as a required argument to savez and savez_compressed function calls?
Because currently only filename is required:

def savez(file, *args, **kwds):
    ...

def savez_compressed(file, *args, **kwds):
    ...

It will be also more compatible with save function:

def save(file, arr, allow_pickle=True, fix_imports=True):
    ...

@billmetangmo
Copy link

Hi . I am using Numpy 1.15.2 and still have this error. When do u think it will be available on a specific version ( not master branch) ?

Thanks

@mattip
Copy link
Member

mattip commented Oct 29, 2018

It is merged into master, so should automatically be in 1.16 when we branch it off master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants