You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is despite the fact that np.load() can parse the original dtype with names, formats, offsets - only np.save() doesn't save it that way. Editing foo.npy by hand lets np.load() produce an identical array to arr (if you try it, the 9th byte must change from 0x66 to 0x96 to allow for the longer descr).
As far as I can tell, fixing this would be as simple as storing str(arr.dtype) instead of arr.dtype.descr in the NPY file. For aligned arrays the two seem to produce the same string. But I'm not sure if there's some reason this wasn't done in the first place.
I'm using NumPy 1.11.1.
The text was updated successfully, but these errors were encountered:
mattip
changed the title
np.save() and np.load() are not idempotent when align=True or fields are discontiguous
BUG: np.save() and np.load() are not idempotent when align=True or fields are discontiguous
Nov 1, 2018
Given an array like this:
The dtype is:
Note the difference with the default
align=False
dtype:Now, the problem is that
np.save('foo.npy', arr)
saves the aligned dtype this way:Then,
np.load('foo.npy')
produces:This is despite the fact that
np.load()
can parse the original dtype withnames, formats, offsets
- onlynp.save()
doesn't save it that way. Editingfoo.npy
by hand letsnp.load()
produce an identical array toarr
(if you try it, the 9th byte must change from 0x66 to 0x96 to allow for the longerdescr
).As far as I can tell, fixing this would be as simple as storing
str(arr.dtype)
instead ofarr.dtype.descr
in the NPY file. For aligned arrays the two seem to produce the same string. But I'm not sure if there's some reason this wasn't done in the first place.I'm using NumPy 1.11.1.
The text was updated successfully, but these errors were encountered: