casacore
Loading...
Searching...
No Matches
Converters.h
Go to the documentation of this file.
1//# Converters.h: The Converters module - Boost.Python converters
2//# Copyright (C) 2006
3//# Associated Universities, Inc. Washington DC, USA.
4//#
5//# This library is free software; you can redistribute it and/or modify it
6//# under the terms of the GNU Library General Public License as published by
7//# the Free Software Foundation; either version 2 of the License, or (at your
8//# option) any later version.
9//#
10//# This library is distributed in the hope that it will be useful, but WITHOUT
11//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13//# License for more details.
14//#
15//# You should have received a copy of the GNU Library General Public License
16//# along with this library; if not, write to the Free Software Foundation,
17//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18//#
19//# Correspondence concerning AIPS++ should be addressed as follows:
20//# Internet email: casa-feedback@nrao.edu.
21//# Postal address: AIPS++ Project Office
22//# National Radio Astronomy Observatory
23//# 520 Edgemont Road
24//# Charlottesville, VA 22903-2475 USA
25
26#ifndef PYRAP_CONVERTERS_H
27#define PYRAP_CONVERTERS_H
28
29//# Includes
30#include <casacore/python/Converters/PycBasicData.h>
31#include <casacore/python/Converters/PycRecord.h>
32#include <casacore/python/Converters/PycValueHolder.h>
33#include <casacore/python/Converters/PycExcp.h>
34
35
36namespace casacore { //# NAMESPACE CASACORE - BEGIN
37
38// <module>
39
40// <summary>
41// Convert Casacore objects to/from Python (using Boost.Python)
42// </summary>
43
44// <use visibility=export>
45
46// <reviewed reviewer="" date="" tests="tConvert" demos="">
47// </reviewed>
48
49// <prerequisite>
50// <li> <linkto class="Record">Record</linkto> class
51// <li> <linkto class="ValueHolder">Record</linkto> class
52// </prerequisite>
53
54// <synopsis>
55// Converters contains functions to convert the important Casacore objects
56// to/from Python using the Boost.Python package.
57// Converters for the following Casacore classes exist:
58// <ul>
59// <li> Scalars of basic data types like Bool, Int, Float, Complex.
60// <li> casacore::String and std::string.
61// <li> casacore::Vector and std::vector of any type which can be converted
62// from a Python scalar, list, tuple, or 1-dim array. They are converted
63// back to a Python list.
64// <li> Record which is converted to/from a Python dict.
65// <li> ValueHolder which is converted to/from the appropriate Python type.
66// A ValueHolder is a class which can hold various value types:
67// <ul>
68// <li> Scalar of any basic data type.
69// <li> Record.
70// <li> N-dim Array of any basic data type. A casacore::Array can be
71// constructed from Python types like tuple, list, and numpy array
72// A Py_None object results in an empty array.
73// The conversion back is done to a numpy array.
74// An empty array is returned as an empty numpy array.
75// <br>Because Casacore arrays are in Fortran order and numpy arrays
76// (preferably) in C order, the axes are reversed during conversion.
77// <br>A 1-dim <src>Array<String></src> object is converted to a list,
78// while a higher dimensioned Array<String> object is converted to/from
79// a dict containing the shape and the values as a list.
80// However, conversion from a numpy string array is supported.
81// </ul>
82// A ValueHolder is for instance used by the Table System to be able
83// to get or put data in a column of any type.
84// It can be used by any Python binding to convert arrays. Class
85// ValueHolder has functions to get or set the array.
86// <li> casacore::IPosition which can be converted
87// from a Python scalar, list, tuple, or 1-dim array.
88// It is converted back to a Python list.
89// An IPosition object represents an array shape or position, so its
90// values are reversed because of the different ordening of
91// Casacore and Python arrays.
92// <li> Exceptions, which are mapped to a Python <src>RuntimeError</src>
93// exception. Only the <src>casacore::IterError</src> exception is mapped
94// to a Python <src>StopIteration</src> exception.
95// </ul>
96// The converts from Python to C++ can handle some special numpy objects.
97// Such objects can also be contained in sequences or dicts.
98// <ul>
99// <li> Elements in a numpy array are called array scalars. They do not have
100// a python type such as <src>int</src>, but instead a type as
101// <src>numpy.int32</src>.
102// The converters can handle such types and convert them correctly to
103// a scalar.
104// <li> A numpy scalar array (e.g. <src>array(1.0)</src> is a somewhat
105// peculiar numpy object. It has an empty shape and cannot be indexed.
106// It is handled correctly by the from converters and handled as a
107// scalar value.
108// <li> An empty numpy object (e.g. <src>array([])</src>) is handled as
109// a None value.
110// </ul>
111// </synopsis>
112
113// </module>
114
115} //# NAMESPACE CASACORE - END
116
117#endif
this file contains all the compiler specific defines
Definition mainpage.dox:28