potocpav / npy-rs

NumPy file format (de-)serialization in Rust
30 stars 7 forks source link

Nested arrays have backwards shapes in `dtype` #19

Open ExpHP opened 5 years ago

ExpHP commented 5 years ago
use npy::NpyData;
use npy::Serializable;

#[derive(npy_derive::Serializable)]
#[derive(Debug, PartialEq)]
struct Array23 {
    field: [[i32; 3]; 2],
}

fn main() {
    println!("{}", <Array23 as Serializable>::dtype().descr());
}
[('field', '<i4', (3,2,)), ]

Observe that the outer dimension of 2 comes last in the output.

(Thankfully, saving a file still writes the correct number of total elements... it's just that, if you read the file in numpy, it'll turn into a 3x2 array)

A fix for this will be included in #15 since it completely replaces the Serializable trait.