@@ -35,45 +35,46 @@ inline Datatype dtype_from_numpy(pybind11::dtype const dt)
3535{
3636 // ref: https://docs.scipy.org/doc/numpy/user/basics.types.html
3737 // ref: https://github.com/numpy/numpy/issues/10678#issuecomment-369363551
38- if (dt.is ( pybind11::dtype (" b" )))
38+ if (dt.char_ () == pybind11::dtype (" b" ). char_ ( ))
3939 return Datatype::CHAR;
40- else if (dt.is ( pybind11::dtype (" B" )))
40+ else if (dt.char_ () == pybind11::dtype (" B" ). char_ ( ))
4141 return Datatype::UCHAR;
42- else if (dt.is ( pybind11::dtype (" short" )))
42+ else if (dt.char_ () == pybind11::dtype (" short" ). char_ ( ))
4343 return Datatype::SHORT;
44- else if (dt.is ( pybind11::dtype (" intc" )))
44+ else if (dt.char_ () == pybind11::dtype (" intc" ). char_ ( ))
4545 return Datatype::INT;
46- else if (dt.is ( pybind11::dtype (" int_" )))
46+ else if (dt.char_ () == pybind11::dtype (" int_" ). char_ ( ))
4747 return Datatype::LONG;
48- else if (dt.is ( pybind11::dtype (" longlong" )))
48+ else if (dt.char_ () == pybind11::dtype (" longlong" ). char_ ( ))
4949 return Datatype::LONGLONG;
50- else if (dt.is ( pybind11::dtype (" ushort" )))
50+ else if (dt.char_ () == pybind11::dtype (" ushort" ). char_ ( ))
5151 return Datatype::USHORT;
52- else if (dt.is ( pybind11::dtype (" uintc" )))
52+ else if (dt.char_ () == pybind11::dtype (" uintc" ). char_ ( ))
5353 return Datatype::UINT;
54- else if (dt.is ( pybind11::dtype (" uint" )))
54+ else if (dt.char_ () == pybind11::dtype (" uint" ). char_ ( ))
5555 return Datatype::ULONG;
56- else if (dt.is ( pybind11::dtype (" ulonglong" )))
56+ else if (dt.char_ () == pybind11::dtype (" ulonglong" ). char_ ( ))
5757 return Datatype::ULONGLONG;
58- else if (dt.is ( pybind11::dtype (" clongdouble" )))
58+ else if (dt.char_ () == pybind11::dtype (" clongdouble" ). char_ ( ))
5959 return Datatype::CLONG_DOUBLE;
60- else if (dt.is ( pybind11::dtype (" cdouble" )))
60+ else if (dt.char_ () == pybind11::dtype (" cdouble" ). char_ ( ))
6161 return Datatype::CDOUBLE;
62- else if (dt.is ( pybind11::dtype (" csingle" )))
62+ else if (dt.char_ () == pybind11::dtype (" csingle" ). char_ ( ))
6363 return Datatype::CFLOAT;
64- else if (dt.is ( pybind11::dtype (" longdouble" )))
64+ else if (dt.char_ () == pybind11::dtype (" longdouble" ). char_ ( ))
6565 return Datatype::LONG_DOUBLE;
66- else if (dt.is ( pybind11::dtype (" double" )))
66+ else if (dt.char_ () == pybind11::dtype (" double" ). char_ ( ))
6767 return Datatype::DOUBLE;
68- else if (dt.is ( pybind11::dtype (" single" )))
68+ else if (dt.char_ () == pybind11::dtype (" single" ). char_ ( ))
6969 return Datatype::FLOAT;
70- else if (dt.is ( pybind11::dtype (" bool" )))
70+ else if (dt.char_ () == pybind11::dtype (" bool" ). char_ ( ))
7171 return Datatype::BOOL;
7272 else
7373 {
7474 pybind11::print (dt);
7575 throw std::runtime_error (
76- " Datatype '...' not known in 'dtype_from_numpy'!" ); // _s.format(dt)
76+ std::string (" Datatype '" ) + dt.char_ () +
77+ std::string (" ' not known in 'dtype_from_numpy'!" )); // _s.format(dt)
7778 }
7879}
7980
0 commit comments