jturner314 / ndarray-npy

.npy and .npz file format support for ndarray
https://docs.rs/ndarray-npy
Apache License 2.0
56 stars 18 forks source link

Match NumPy behavior regarding ".npy" extension for names in .npz files #48

Closed jturner314 closed 2 months ago

jturner314 commented 3 years ago

As @jonathanstrong pointed out in #46, NumPy and ndarray-npy currently behave differently regarding the names of the arrays in .npz files. When writing a .npz file, NumPy unconditionally adds ".npy" to every name. When generating the public list of names when reading a .npz file, NumPy strips a single ".npy" (if present) from each name. When accessing an array in a .npz file by name, it first checks if that exact name is in the .npz file, and if not, it then tries the name with ".npy" appended. While I personally dislike the inconsistency/implicitness of this behavior, ndarray-npy should consider following it for compatibility with NumPy.