Closed matklad closed 5 years ago
This is a good idea. I think a good API would be this:
pub fn read_npy<P, T>(path: P) -> Result<T, ReadNpyError>
where
P: AsRef<std::path::Path>,
T: ReadNpyExt,
{
// ...
}
pub fn write_npy<P, T>(path: P, array: T) -> Result<(), WriteNpyError>
where
P: AsRef<std::path::Path>,
T: WriteNpyExt,
{
// ...
}
(or maybe use ArrayBase
instead of T
) to match std::fs::read
and std::fs::write
.
I'll need to work on the error handling to make this work cleanly (since the version of ReadNpyError
on master
doesn't have an Io
variant).
Hi! I've tried using this crate today, and it works great!
However, it was slightly difficult to figure out due to the use of extension traits. As each trait has only one method, and is implemented on a single type, perhaps just providing
would give a simpler API? It also matches
std::fs::read_to_string
andnp.save
style