Loading...
Searching...
No Matches
PycArrayComCC.h File Reference
`#include <boost/python.hpp>`
`#include <numpy/arrayobject.h>`

Go to the source code of this file.

## Classes

struct | TypeConvTraits< T >
struct | TypeConvTraits< casacore::Bool >
struct | TypeConvTraits< casacore::uChar >
struct | TypeConvTraits< casacore::Short >
struct | TypeConvTraits< casacore::uShort >
struct | TypeConvTraits< casacore::Int >
struct | TypeConvTraits< casacore::uInt >
struct | TypeConvTraits< casacore::Int64 >
struct | TypeConvTraits< casacore::uInt64 >
struct | TypeConvTraits< casacore::Float >
struct | TypeConvTraits< casacore::Double >
struct | TypeConvTraits< casacore::Complex >
struct | TypeConvTraits< casacore::DComplex >
struct | TypeConvTraits< casacore::String >
struct | TypeConvTraits< signed char >
| This one is only used to convert numpy BYTE and SBYTE to casa short. More...

## Functions

Bool | PycArrayCheck (PyObject *obj_ptr)
| Check if the PyObject is an array object.
Bool | isImported ()
| Check if the API is or can be imported.
void | loadAPI ()
ValueHolder | makeArray (PyObject *obj_ptr, Bool copyData)
| Convert the python array to a Casacore array in the ValueHolder.
template boost::python::object | makePyArrayObject (casacore::Array< Bool > const &arr)
template boost::python::object | makePyArrayObject (casacore::Array< uChar > const &arr)
template boost::python::object | makePyArrayObject (casacore::Array< Short > const &arr)
template boost::python::object | makePyArrayObject (casacore::Array< uShort > const &arr)
template boost::python::object | makePyArrayObject (casacore::Array< Int > const &arr)
template boost::python::object | makePyArrayObject (casacore::Array< uInt > const &arr)
template boost::python::object | makePyArrayObject (casacore::Array< Int64 > const &arr)
template boost::python::object | makePyArrayObject (casacore::Array< Float > const &arr)
template boost::python::object | makePyArrayObject (casacore::Array< Double > const &arr)
template boost::python::object | makePyArrayObject (casacore::Array< Complex > const &arr)
template boost::python::object | makePyArrayObject (casacore::Array< DComplex > const &arr)

## Function Documentation

## isImported()

Bool isImported | ( |  | ) |

Check if the API is or can be imported.

PySys_GetObject uses char* instead of const char*, so use a cast.

Definition at line 44 of file PycArrayComCC.h.

References PYC_USE_PYARRAY.

Referenced by PycArrayCheck().

## loadAPI()

void loadAPI | ( |  | ) |

Definition at line 54 of file PycArrayComCC.h.

References importArray(), and PYC_USE_PYARRAY.

Referenced by PycArrayCheck().

## makeArray()

ValueHolder makeArray | ( | PyObject * | obj_ptr,
|  | Bool | copyData )

Convert the python array to a Casacore array in the ValueHolder.

If copyData is True, the array data is always copied. Otherwise only if needed.

incr refcount, because ~object decrements it

Swap axes, because Casacore has row minor and Python row major order. A scalar is treated as a vector with length 1.

Assert array is contiguous now. If the array is empty, numarray still sees it as non-contiguous.

&& PyArray_ISALIGNED(po) fails on MIPS (see issue 531)

Create the correct array.

Some types can be the same as other types, so they cannot be used in the switch (compiler complains). This is true for BYTE and SBYTE which can equal to BOOL in numarray. Similarly for STRING which exists for numpy and is set to INT for numarray.

Copy using signed char, because uChar is mapped to Short in the Traits.

Definition at line 278 of file PycArrayComCC.h.

References AlwaysAssert, ArrayCopyStr_toArray(), ArrayCopyUnicode_toArray(), PycArrayCheck(), and ArrayCopy< T >::toArray().

## makePyArrayObject() [1/11]

template boost::python::object makePyArrayObject | ( | casacore::Array< Bool > const & | arr | ) |

## makePyArrayObject() [2/11]

template boost::python::object makePyArrayObject | ( | casacore::Array< Complex > const & | arr | ) |

## makePyArrayObject() [3/11]

template boost::python::object makePyArrayObject | ( | casacore::Array< DComplex > const & | arr | ) |

## makePyArrayObject() [4/11]

template boost::python::object makePyArrayObject | ( | casacore::Array< Double > const & | arr | ) |

## makePyArrayObject() [5/11]

template boost::python::object makePyArrayObject | ( | casacore::Array< Float > const & | arr | ) |

## makePyArrayObject() [6/11]

template boost::python::object makePyArrayObject | ( | casacore::Array< Int > const & | arr | ) |

## makePyArrayObject() [7/11]

template boost::python::object makePyArrayObject | ( | casacore::Array< Int64 > const & | arr | ) |

## makePyArrayObject() [8/11]

template boost::python::object makePyArrayObject | ( | casacore::Array< Short > const & | arr | ) |

## makePyArrayObject() [9/11]

template boost::python::object makePyArrayObject | ( | casacore::Array< uChar > const & | arr | ) |

## makePyArrayObject() [10/11]

template boost::python::object makePyArrayObject | ( | casacore::Array< uInt > const & | arr | ) |

## makePyArrayObject() [11/11]

template boost::python::object makePyArrayObject | ( | casacore::Array< uShort > const & | arr | ) |

## PycArrayCheck()

Bool PycArrayCheck | ( | PyObject * | obj_ptr | ) |

Check if the PyObject is an array object.

Definition at line 35 of file PycArrayComCC.h.

References isImported(), and loadAPI().

Referenced by makeArray().