23#include <ElementsKernel/Exception.h>
30using boost::endian::little_uint16_t;
31using boost::endian::little_uint32_t;
37 std::vector<size_t> shape;
38 std::vector<std::string> attr_names;
42 throw Elements::Exception() <<
"Can not cast " << dtype <<
" into " <<
typeid(T).name();
44 if (!attr_names.
empty()) {
45 n_elements *= attr_names.
size();
48 std::vector<T> data(n_elements);
49 input.
read(
reinterpret_cast<char*
>(&data[0]),
sizeof(T) * data.size());
50 return {shape, attr_names,
std::move(data)};
void readNpyHeader(std::istream &input, std::string &dtype, std::vector< size_t > &shape, std::vector< std::string > &attrs, size_t &n_elements)
NdArray< T > readNpy(std::istream &input)