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

Namespaces

 numpy
 

Classes

struct  casa_array_from_python
 
struct  casa_array_to_python
 Convert Array to Python. More...
 
class  pyregistry
 Prevent a converter from being registered multiple times. More...
 
struct  casa_string_to_python_str
 Convert a String object to python. More...
 
struct  casa_string_from_python_str
 Convert a String object from python. More...
 
struct  default_policy
 Default operations on all containers for conversion from Python container to C++ one. More...
 
struct  stl_variable_capacity_policy
 Operations on containers that have variable capacity for conversion from Python container to C++ one. More...
 
struct  casa_variable_capacity_policy
 
struct  casa_reversed_variable_capacity_policy
 
struct  to_list
 A wrapper of a conversion function to convert a STL vector to a Python list. More...
 
struct  to_list< casacore::IPosition >
 
struct  to_list< std::vector< bool > >
 
struct  to_list< std::vector< casacore::String > >
 
struct  to_list< casacore::Array< casacore::String > >
 
struct  to_list< casacore::Vector< casacore::String > >
 
struct  std_vector_to_list
 Converts an STL vector or casa Array of T objects to Python list. More...
 
struct  casa_array_to_list
 
struct  casa_vector_to_list
 
struct  casa_iposition_to_list
 
struct  from_python_sequence
 Conversion of Python sequence to C++ container. More...
 
struct  convert_casa_string
 Register the String conversion. More...
 
struct  convert_casa_iposition
 Register the IPosition conversion. More...
 
struct  convert_std_vector
 Register the std::vector conversions. More...
 
struct  convert_casa_vector
 Register the casacore::Vector conversions. More...
 
struct  casa_record_to_python
  More...
 
struct  casa_record_from_python
 
struct  convert_casa_record
 Register the Record conversion. More...
 
struct  casa_value_to_python
  More...
 
struct  casa_value_from_python
 
struct  convert_casa_valueholder
 Register the ValueHolder conversion. More...
 

Functions

Bool PycArrayCheck (PyObject *obj_ptr)
  More...
 
Bool PycArrayScalarCheck (PyObject *obj_ptr)
 Check if the PyObject is an array scalar object. More...
 
DataType PycArrayScalarType (PyObject *obj_ptr)
 Get the data type of the array scalar object. More...
 
template<typename T >
boost::python::object makePyArrayObject (casacore::Array< T > const &arr)
 Do the actual making of the PyArrayObject. More...
 
template<>
boost::python::object makePyArrayObject (casacore::Array< String > const &arr)
 
bool getSeqObject (boost::python::object &py_obj)
 Check if the given object is a sequence object. More...
 
void register_convert_casa_string ()
 
void register_convert_casa_iposition ()
 
template<typename T >
void register_convert_std_vector ()
 
template<typename T >
void register_convert_casa_vector ()
 
void register_convert_basicdata ()
 Register all standard basic conversions. More...
 
void translate_iterexcp (const casacore::IterError &e)
 Convert an IterError exception to a Python StopIteration. More...
 
void register_convert_excp ()
 Register exception translators for casacore::IterError. More...
 
boost::python::object PycImport (const String &moduleName, const String &className)
 This function can be used to create a Python class from C++. More...
 
void register_convert_casa_record ()
 
void register_convert_casa_valueholder ()
 

Function Documentation

◆ getSeqObject()

bool casacore::python::getSeqObject ( boost::python::object &  py_obj)

Check if the given object is a sequence object.

If so, return true. py_obj gets changed if the given object was a scalar numpy/numarray. In that case it is flattened.

Referenced by casacore::python::from_python_sequence< ContainerType, ConversionPolicy >::construct(), and casacore::python::from_python_sequence< ContainerType, ConversionPolicy >::convertible().

◆ makePyArrayObject() [1/2]

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

◆ makePyArrayObject() [2/2]

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

Do the actual making of the PyArrayObject.

Specialize for strings.

Referenced by casacore::python::casa_array_to_python< T >::makeobject().

◆ PycArrayScalarCheck()

Bool casacore::python::PycArrayScalarCheck ( PyObject *  obj_ptr)

◆ PycArrayScalarType()

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

◆ PycImport()

boost::python::object casacore::python::PycImport ( const String moduleName,
const String className 
)

This function can be used to create a Python class from C++.


It returns the object to be used to create a class instance. It initializes Python, imports the main module and the given module, and finally creates the class object. Before the import it adds the working directory to the Python module search path, because Boost-Python does not do that.
For example:

// Create the class object.
boost::python::object pyClass =
casacore::python::PycImport("modulenm", "classnm");
// Register the converters needed.
casacore::python::register_convert_std_vector<Bool>();
casacore::python::register_convert_std_vector<Int>();
casacore::python::register_convert_std_vector<String>();
// Instantiate the Python class object with possible arguments
// for the __init__ function.
boost::python::object classObject = pyClass(arg1, arg2);
// Invoke the 'setup' function in the Python object
boost::python::object result =
classObject.attr("setup")(arg1, arg2, arg3);
// Extract the result (a dict in this case) as a Record.
Record rec = boost::python::extract<Record>(result);
boost::python::object PycImport(const String &moduleName, const String &className)
This function can be used to create a Python class from C++.
void register_convert_basicdata()
Register all standard basic conversions.
void register_convert_casa_record()
Definition: PycRecord.h:90
void register_convert_excp()
Register exception translators for casacore::IterError.
void register_convert_casa_valueholder()

◆ register_convert_basicdata()

void casacore::python::register_convert_basicdata ( )

Register all standard basic conversions.

These are String, IPosition, Vector<String>, Vector<Int>, Vector<Double>, Vector<DComplex>.

◆ register_convert_casa_iposition()

void casacore::python::register_convert_casa_iposition ( )
inline

Definition at line 593 of file PycBasicData.h.

References casacore::python::convert_casa_iposition::reg().

◆ register_convert_casa_record()

void casacore::python::register_convert_casa_record ( )
inline

Definition at line 90 of file PycRecord.h.

References casacore::python::convert_casa_record::reg().

◆ register_convert_casa_string()

void casacore::python::register_convert_casa_string ( )
inline

Definition at line 585 of file PycBasicData.h.

References casacore::python::convert_casa_string::reg().

◆ register_convert_casa_valueholder()

void casacore::python::register_convert_casa_valueholder ( )
inline

◆ register_convert_casa_vector()

template<typename T >
void casacore::python::register_convert_casa_vector ( )
inline

Definition at line 632 of file PycBasicData.h.

References casacore::python::convert_casa_vector< T >::reg().

◆ register_convert_excp()

void casacore::python::register_convert_excp ( )

Register exception translators for casacore::IterError.

◆ register_convert_std_vector()

template<typename T >
void casacore::python::register_convert_std_vector ( )
inline

Definition at line 612 of file PycBasicData.h.

References casacore::python::convert_std_vector< T >::reg().

◆ translate_iterexcp()

void casacore::python::translate_iterexcp ( const casacore::IterError e)

Convert an IterError exception to a Python StopIteration.

In this way an iteration loop can be done.