-
Notifications
You must be signed in to change notification settings - Fork 174
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
Add routines for saving/loading arrays in npy format #581
Conversation
@certik @milancurcic @MRedies Please have a look at this PR for supporting the npy format. The saving routines are close to Matthias implementation in https://github.com/MRedies/NPY-for-Fortran, the main difference is that version 1.0 of the format is used by default, rather than always version 2.0, also the padding of the header seemed off by two bytes in some cases. The loading routines are new, they need some stress testing and maybe some polishing, but the basic functionality is there and we can do a full round trip via the npy format now. We maybe should discuss how we handle the Also, for error reporting in binary chunks a hexdump like displaying function for detailed error messages might be useful, or at least for debugging ;). But this might be material for another project. |
I didn't have a chance to test it, but it looks like a sensible and concise version of what I did before. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Only some minor comments.
Thank you @awvwgk for this. I am not a Python user, but I am sure it will be usefull to many people.
libnpy seems to be a library that provides simple routines for saving a C or Fortran array to a data file using NumPy's own binary format.
|
|
Additionally, if attempt to save some array slice |
Agreed @awvwgk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am happy with the changes. thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you!
Thanks everybody for the feedback and the reviews. I'll go ahead and merge. |
Nice work here. Sorry I join the thread late, but shouldn't stdlib/src/stdlib_io_npy_save.fypp Line 130 in 7758a1d
only be allocated when stat /= 0 ? (similar to iostat )
|
Good catch. Before this is lost at the end of this thread, let's open a new issue or setup a quick patch to fix it. |
Related:
Hexdumps of
npy
files for reference:Tests and error outputs: