| 539 | |
| 540 | template <typename Scalar> |
| 541 | inline void SaveArrayAsNumpy( |
| 542 | const std::string& filename, bool fortran_order, unsigned int n_dims, |
| 543 | const unsigned long shape[], const std::vector<Scalar>& data) { |
| 544 | Typestring typestring_o(data); |
| 545 | std::string typestring = typestring_o.str(); |
| 546 | |
| 547 | std::ofstream stream(filename, std::ofstream::binary); |
| 548 | if (!stream) { |
| 549 | fprintf(stderr, "io error: failed to open a file."); |
| 550 | } |
| 551 | |
| 552 | std::vector<ndarray_len_t> shape_v(shape, shape + n_dims); |
| 553 | write_header(stream, typestring, fortran_order, shape_v); |
| 554 | |
| 555 | auto size = static_cast<size_t>(comp_size(shape_v)); |
| 556 | |
| 557 | stream.write(reinterpret_cast<const char*>(data.data()), sizeof(Scalar) * size); |
| 558 | } |
| 559 | |
| 560 | template <typename Scalar> |
| 561 | inline void LoadArrayFromNumpy( |
nothing calls this directly
no test coverage detected