// Copyright Jim Bosch & Ankit Daftery 2010-2012.
// Copyright Stefan Seefeld 2016.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include
#include
namespace p = boost::python;
namespace np = boost::python::numpy;
template
np::dtype accept(T) {
return np::dtype::get_builtin();
}
BOOST_PYTHON_MODULE(dtype_ext)
{
np::initialize();
// wrap dtype equivalence test, since it isn't available in Python API.
p::def("equivalent", np::equivalent);
// integers, by number of bits
p::def("accept_int8", accept<:int8_t>);
p::def("accept_uint8", accept<:uint8_t>);
p::def("accept_int16", accept<:int16_t>);
p::def("accept_uint16", accept<:uint16_t>);
p::def("accept_int32", accept<:int32_t>);
p::def("accept_uint32", accept<:uint32_t>);
p::def("accept_int64", accept<:int64_t>);
p::def("accept_uint64", accept<:uint64_t>);
// integers, by C name according to NumPy
p::def("accept_bool_", accept);
p::def("accept_byte", accept);
p::def("accept_ubyte", accept);
p::def("accept_short", accept);
p::def("accept_ushort", accept);
p::def("accept_intc", accept);
p::def("accept_uintc", accept);
// floats and complex
p::def("accept_float32", accept);
p::def("accept_complex64", accept< std::complex >);
p::def("accept_float64", accept);
p::def("accept_complex128", accept< std::complex >);
if (sizeof(long double) > sizeof(double)) {
p::def("accept_longdouble", accept);
p::def("accept_clongdouble", accept< std::complex >);
}
}