24 #ifndef NDARRAY_SWIG_Vector_h_INCLUDED
25 #define NDARRAY_SWIG_Vector_h_INCLUDED
40 template <
typename T,
int N>
52 PyObject * r = PyTuple_New(N);
53 for (
int i=0; i<N; ++i) {
63 static PyTypeObject
const *
getPyType() {
return &PyTuple_Type; }
79 if (!PySequence_Check(p.get())) {
80 PyErr_Format(PyExc_TypeError,
"Expected a Python sequence of length %i.",N);
83 if (PySequence_Size(p.get()) != N) {
84 PyErr_Format(PyExc_ValueError,
"Incorrect sequence length for Vector<T,%i>", N);
104 for (
int n=0; n<N; ++n) {
105 PyPtr item(PySequence_ITEM(p.get(),n),
false);
106 if (!item)
return false;
118 #endif // !NDARRAY_SWIG_Vector_h_INCLUDED
boost::intrusive_ptr< PyObject > PyPtr
A reference-counting smart pointer for PyObject.
static PyTypeObject const * getPyType()
Return the Python TypeObject that corresponds to the object the toPython() function returns...
#define NDARRAY_ASSERT(ARG)
A fixed-size 1D array class.
A class providing Python conversion functions for T.
static PyObject * toPython(Vector< T, N > const &input)
Convert a Vector to a new Python object.
static bool fromPythonStage1(PyPtr &p)
Check if a Python object is convertible to T and optionally begin the conversion by replacing the inp...
Python C-API conversions for standard numeric types.
static bool fromPythonStage2(PyPtr const &p, Vector< T, N > &output)
Complete a Python to C++ conversion begun with fromPythonStage1().