llohse / libnpy

C++ library for reading and writing of numpy's .npy files
MIT License
361 stars 72 forks source link

Malformed .npy header due to comma separated digit grouping. #37

Closed pauljurczak closed 6 months ago

pauljurczak commented 6 months ago

I'm using v1.0.1 and I'm getting malformed headers for dimensions larger than 999, e.g.

npy::npy_data_ptr<float> npyData{.data_ptr=depthMap.data(), .shape={2621, 401}};

will produce this header

�NUMPYF{'descr': '<f4', 'fortran_order': False, 'shape': (2,621, 401), }

which has the wrong dimensions of [2, 621, 401]. This problem appears only in certain contexts. A simple test in a minimal context doesn't reproduce this problem.

I tried to force the C standard formatting with std::cout.imbue(std::locale("C")); to no effect.