casacore
Classes | Functions
casacore::python::numpy Namespace Reference

Classes

struct  array_scalar_from_python
 Struct with static functions to convert a numpy array scalar to the templated type (e.g. More...
 
struct  ArrayCopy
 Copy/convert the array data as needed. More...
 
struct  ArrayCopy< Complex >
 
struct  ArrayCopy< DComplex >
 
struct  ArrayCopy< String >
 

Functions

Bool PycArrayCheck (PyObject *obj_ptr)
 Check if the PyObject is an array object. More...
 
Bool isImported ()
 Check if the API is or can be imported. More...
 
Bool canImport ()
 
Bool importArray ()
 
void loadAPI ()
 
ValueHolder makeArray (PyObject *obj_ptr, Bool copyData)
 Convert the python array to a Casacore array in the ValueHolder. More...
 
Array< StringArrayCopyStr_toArray (const IPosition &shape, void *data, uInt slen)
 
template<typename T >
boost::python::object makePyArrayObject (casacore::Array< T > const &arr)
 Convert a Casacore array to a Python array object. More...
 
bool PycArrayScalarCheck (PyObject *obj, int &type)
 Check if it is an array scalar object. More...
 
DataType PycArrayScalarType (PyObject *obj_ptr)
 Get the data type of the array scalar object. More...
 
ValueHolder makeScalar (PyObject *obj, int type)
 Make a scalar object. More...
 
void register_convert_arrayscalars ()
 Register all array scalar converters. More...
 
template<typename T >
getScalar (const ValueHolder &)
 Templated helper function to get a value from a ValueHolder. More...
 
template<>
Bool getScalar (const ValueHolder &vh)
 Templated helper function to get a value from a ValueHolder. More...
 
template<>
Char getScalar (const ValueHolder &vh)
 Templated helper function to get a value from a ValueHolder. More...
 
template<>
uChar getScalar (const ValueHolder &vh)
 Templated helper function to get a value from a ValueHolder. More...
 
template<>
Short getScalar (const ValueHolder &vh)
 Templated helper function to get a value from a ValueHolder. More...
 
template<>
uShort getScalar (const ValueHolder &vh)
 Templated helper function to get a value from a ValueHolder. More...
 
template<>
Int getScalar (const ValueHolder &vh)
 Templated helper function to get a value from a ValueHolder. More...
 
template<>
uInt getScalar (const ValueHolder &vh)
 Templated helper function to get a value from a ValueHolder. More...
 
template<>
Long getScalar (const ValueHolder &vh)
 Templated helper function to get a value from a ValueHolder. More...
 
template<>
uLong getScalar (const ValueHolder &vh)
 Templated helper function to get a value from a ValueHolder. More...
 
template<>
Int64 getScalar (const ValueHolder &vh)
 Templated helper function to get a value from a ValueHolder. More...
 
template<>
uInt64 getScalar (const ValueHolder &vh)
 Templated helper function to get a value from a ValueHolder. More...
 
template<>
Float getScalar (const ValueHolder &vh)
 Templated helper function to get a value from a ValueHolder. More...
 
template<>
Double getScalar (const ValueHolder &vh)
 Templated helper function to get a value from a ValueHolder. More...
 
template<>
Complex getScalar (const ValueHolder &vh)
 Templated helper function to get a value from a ValueHolder. More...
 
template<>
DComplex getScalar (const ValueHolder &vh)
 Templated helper function to get a value from a ValueHolder. More...
 

Function Documentation

◆ ArrayCopyStr_toArray()

Array<String> casacore::python::numpy::ArrayCopyStr_toArray ( const IPosition shape,
void *  data,
uInt  slen 
)

◆ canImport()

Bool casacore::python::numpy::canImport ( )
inline

Definition at line 35 of file PycArrayNP.h.

◆ getScalar() [1/16]

template<typename T >
T casacore::python::numpy::getScalar ( const ValueHolder )
inline

◆ getScalar() [2/16]

template<>
Bool casacore::python::numpy::getScalar ( const ValueHolder )
inline

Templated helper function to get a value from a ValueHolder.

Specialize for each type supported.

Definition at line 67 of file PycArrayNP.h.

References casacore::ValueHolder::asBool().

◆ getScalar() [3/16]

template<>
Char casacore::python::numpy::getScalar ( const ValueHolder )
inline

Templated helper function to get a value from a ValueHolder.

Specialize for each type supported.

Definition at line 69 of file PycArrayNP.h.

References casacore::ValueHolder::asShort().

◆ getScalar() [4/16]

template<>
uChar casacore::python::numpy::getScalar ( const ValueHolder )
inline

Templated helper function to get a value from a ValueHolder.

Specialize for each type supported.

Definition at line 71 of file PycArrayNP.h.

References casacore::ValueHolder::asuChar().

◆ getScalar() [5/16]

template<>
Short casacore::python::numpy::getScalar ( const ValueHolder )
inline

Templated helper function to get a value from a ValueHolder.

Specialize for each type supported.

Definition at line 73 of file PycArrayNP.h.

References casacore::ValueHolder::asShort().

◆ getScalar() [6/16]

template<>
uShort casacore::python::numpy::getScalar ( const ValueHolder )
inline

Templated helper function to get a value from a ValueHolder.

Specialize for each type supported.

Definition at line 75 of file PycArrayNP.h.

References casacore::ValueHolder::asuShort().

◆ getScalar() [7/16]

template<>
Int casacore::python::numpy::getScalar ( const ValueHolder )
inline

Templated helper function to get a value from a ValueHolder.

Specialize for each type supported.

Definition at line 77 of file PycArrayNP.h.

References casacore::ValueHolder::asInt().

◆ getScalar() [8/16]

template<>
uInt casacore::python::numpy::getScalar ( const ValueHolder )
inline

Templated helper function to get a value from a ValueHolder.

Specialize for each type supported.

Definition at line 79 of file PycArrayNP.h.

References casacore::ValueHolder::asuInt().

◆ getScalar() [9/16]

template<>
Long casacore::python::numpy::getScalar ( const ValueHolder )
inline

Templated helper function to get a value from a ValueHolder.

Specialize for each type supported.

Definition at line 81 of file PycArrayNP.h.

References casacore::ValueHolder::asInt().

◆ getScalar() [10/16]

template<>
uLong casacore::python::numpy::getScalar ( const ValueHolder )
inline

Templated helper function to get a value from a ValueHolder.

Specialize for each type supported.

Definition at line 83 of file PycArrayNP.h.

References casacore::ValueHolder::asuInt().

◆ getScalar() [11/16]

template<>
Int64 casacore::python::numpy::getScalar ( const ValueHolder )
inline

Templated helper function to get a value from a ValueHolder.

Specialize for each type supported.

Definition at line 85 of file PycArrayNP.h.

References casacore::ValueHolder::asInt().

◆ getScalar() [12/16]

template<>
uInt64 casacore::python::numpy::getScalar ( const ValueHolder )
inline

Templated helper function to get a value from a ValueHolder.

Specialize for each type supported.

Definition at line 87 of file PycArrayNP.h.

References casacore::ValueHolder::asuInt().

◆ getScalar() [13/16]

template<>
Float casacore::python::numpy::getScalar ( const ValueHolder )
inline

Templated helper function to get a value from a ValueHolder.

Specialize for each type supported.

Definition at line 89 of file PycArrayNP.h.

References casacore::ValueHolder::asFloat().

◆ getScalar() [14/16]

template<>
Double casacore::python::numpy::getScalar ( const ValueHolder )
inline

Templated helper function to get a value from a ValueHolder.

Specialize for each type supported.

Definition at line 91 of file PycArrayNP.h.

References casacore::ValueHolder::asDouble().

◆ getScalar() [15/16]

template<>
Complex casacore::python::numpy::getScalar ( const ValueHolder )
inline

Templated helper function to get a value from a ValueHolder.

Specialize for each type supported.

Definition at line 93 of file PycArrayNP.h.

References casacore::ValueHolder::asComplex().

◆ getScalar() [16/16]

template<>
DComplex casacore::python::numpy::getScalar ( const ValueHolder )
inline

Templated helper function to get a value from a ValueHolder.

Specialize for each type supported.

Definition at line 95 of file PycArrayNP.h.

References casacore::ValueHolder::asDComplex().

◆ importArray()

Bool casacore::python::numpy::importArray ( )

◆ isImported()

Bool casacore::python::numpy::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 42 of file PycArrayComCC.h.

References PYC_USE_PYARRAY.

Referenced by PycArrayCheck().

◆ loadAPI()

void casacore::python::numpy::loadAPI ( )

Definition at line 52 of file PycArrayComCC.h.

References importArray(), and PYC_USE_PYARRAY.

Referenced by PycArrayCheck().

◆ makeArray()

ValueHolder casacore::python::numpy::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.

◆ makePyArrayObject()

template<typename T >
boost::python::object casacore::python::numpy::makePyArrayObject ( casacore::Array< T > const &  arr)

Convert a Casacore array to a Python array object.

◆ makeScalar()

ValueHolder casacore::python::numpy::makeScalar ( PyObject *  obj,
int  type 
)

◆ PycArrayScalarCheck()

bool casacore::python::numpy::PycArrayScalarCheck ( PyObject *  obj,
int &  type 
)

◆ PycArrayScalarType()

DataType casacore::python::numpy::PycArrayScalarType ( PyObject *  obj_ptr)

Get the data type of the array scalar object.

It returns TpBool, TpInt, TpFloat, or TpComplex. TpOther is returned if unrecognized.

◆ register_convert_arrayscalars()

void casacore::python::numpy::register_convert_arrayscalars ( )

Register all array scalar converters.