Closed mariogeiger closed 7 years ago
Serializing a simple float is not implemented (not hard to do), just structs. But you can convert your Vec<f32>
into a vector of structs that derives the NpyData
trait. For example (may not compile, I'm on mobile):
#[derive(NpyData)]
struct Data {
field: f32,
}
It is possible to unsafely transmute the Vec<f32>
into Vec<Data>
or just copy it over. Vec<Data>
can be serialized. It will create a numpy structured array, which can be converted to np.float32
easily.
Closing. If the suggested approach doesn't work, feel free to re-open the issue.
I dont manage to save a
Vec<f32>
withto_file
becauseNpyData
is not implemented forf32
.Is there a way to save a
Vec<f32>
such that when I load it from python it is a simple array of typenp.float32
?