write1 seems to give wrong shape info
nilsbecker opened this issue · 10 comments
i just wrote a fortran-ordered bigarray using write1. the file starts with
�NUMPY��F�{'descr': '<f8', 'fortran_order': True, 'shape': (184), }
note that the shape is not a python tuple (this would have to be (184,)).
numpy refuses to load it, probably for this reason. indeed after i edit the file manually i can import it.
(maybe add a test case for write/read in all dimensions?)
actually the file still seems to be broken: after editing the shape, the file is loaded but contains garbled values ?!
the same happens if i first convert the array to a c-layout Bigarray.Array1.t
os x, python 2.7.11, numpy 1.11.2
if i wrap the vector in an extra dimension and write it with write2, the import in numpy works as expected. conclusion: write1 is broken, write2 ok.
Could you attach the problematic npy file ? Also are you using the current github tip or the opam package ?
i was using the opam package. the file generated with write1 is here:
tvals.npy.zip
the input bigarrays were actually vectors from lacaml - but that should not matter i think..
I just tweaked the github tip to fix this and added some tests for the single dimension case, would you mind giving it a try ?
it's looking good now! i opam pinned and redid my example, and the shape is now reported as (184,) in the file. numpy successfully loads it. thanks!
Perfect, thanks for reporting the issue!