29 #ifndef PYRAP_PYCARRAYNP_H
30 #define PYRAP_PYCARRAYNP_H
33 #include <boost/python.hpp>
34 #include <boost/python/object.hpp>
37 #include <numpy/arrayobject.h>
39 namespace casacore {
namespace python {
namespace numpy {
41 #define PYC_USE_PYARRAY "numpy"
43 #undef PYC_USE_PYARRAY
65 template<
typename T> T
getScalar (
const ValueHolder&);
77 {
return vh.
asInt(); }
81 {
return vh.
asInt(); }
85 {
return vh.
asInt(); }
100 template <
typename T>
105 boost::python::converter::registry::push_back(
108 boost::python::type_id<T>());
124 boost::python::converter::rvalue_from_python_stage1_data*
data)
126 using namespace boost::python;
127 void* storage = ((converter::rvalue_from_python_storage<T>*)
128 data)->storage.bytes;
130 data->convertible = storage;
133 *
static_cast<T*
>(storage) = getScalar<T> (
makeScalar(obj_ptr,
type));
Bool asBool() const
Get the value.
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
std::complex< Float > Complex
DataType PycArrayScalarType(PyObject *obj_ptr)
Get the data type of the array scalar object.
static void * convertible(PyObject *obj_ptr)
Check if it is a type we can convert.
DComplex asDComplex() const
unsigned long long uInt64
virtual casacore::String type() const
Implements RegionShape::type.
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
ValueHolder makeScalar(PyObject *obj, int type)
Make a scalar object.
Complex asComplex() const
std::complex< Double > DComplex
A holder for a value of any basic Casacore data type.
void register_convert_arrayscalars()
Register all array scalar converters.
Struct with static functions to convert a numpy array scalar to the templated type (e...
bool Bool
Define the standard types used by Casacore.
T getScalar(const ValueHolder &)
Templated helper function to get a value from a ValueHolder.
bool PycArrayScalarCheck(PyObject *obj, int &type)
Check if it is an array scalar object.
array_scalar_from_python()
static void construct(PyObject *obj_ptr, boost::python::converter::rvalue_from_python_stage1_data *data)
Constructs a T from a Python array scalar object.
#define casacore
<X11/Intrinsic.h> #defines true, false, casacore::Bool, and String.