casacore
Loading...
Searching...
No Matches
python
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
namespace
casacore
{
// # NAMESPACE CASACORE - BEGIN
36
37
// <module>
38
39
// <summary>
40
// Convert Casacore objects to/from Python (using Boost.Python)
41
// </summary>
42
43
// <use visibility=export>
44
45
// <reviewed reviewer="" date="" tests="tConvert" demos="">
46
// </reviewed>
47
48
// <prerequisite>
49
// <li> <linkto class="Record">Record</linkto> class
50
// <li> <linkto class="ValueHolder">Record</linkto> class
51
// </prerequisite>
52
53
// <synopsis>
54
// Converters contains functions to convert the important Casacore objects
55
// to/from Python using the Boost.Python package.
56
// Converters for the following Casacore classes exist:
57
// <ul>
58
// <li> Scalars of basic data types like Bool, Int, Float, Complex.
59
// <li> casacore::String and std::string.
60
// <li> casacore::Vector and std::vector of any type which can be converted
61
// from a Python scalar, list, tuple, or 1-dim array. They are converted
62
// back to a Python list.
63
// <li> Record which is converted to/from a Python dict.
64
// <li> ValueHolder which is converted to/from the appropriate Python type.
65
// A ValueHolder is a class which can hold various value types:
66
// <ul>
67
// <li> Scalar of any basic data type.
68
// <li> Record.
69
// <li> N-dim Array of any basic data type. A casacore::Array can be
70
// constructed from Python types like tuple, list, and numpy array
71
// A Py_None object results in an empty array.
72
// The conversion back is done to a numpy array.
73
// An empty array is returned as an empty numpy array.
74
// <br>Because Casacore arrays are in Fortran order and numpy arrays
75
// (preferably) in C order, the axes are reversed during conversion.
76
// <br>A 1-dim <src>Array<String></src> object is converted to a list,
77
// while a higher dimensioned Array<String> object is converted to/from
78
// a dict containing the shape and the values as a list.
79
// However, conversion from a numpy string array is supported.
80
// </ul>
81
// A ValueHolder is for instance used by the Table System to be able
82
// to get or put data in a column of any type.
83
// It can be used by any Python binding to convert arrays. Class
84
// ValueHolder has functions to get or set the array.
85
// <li> casacore::IPosition which can be converted
86
// from a Python scalar, list, tuple, or 1-dim array.
87
// It is converted back to a Python list.
88
// An IPosition object represents an array shape or position, so its
89
// values are reversed because of the different ordening of
90
// Casacore and Python arrays.
91
// <li> Exceptions, which are mapped to a Python <src>RuntimeError</src>
92
// exception. Only the <src>casacore::IterError</src> exception is mapped
93
// to a Python <src>StopIteration</src> exception.
94
// </ul>
95
// The converts from Python to C++ can handle some special numpy objects.
96
// Such objects can also be contained in sequences or dicts.
97
// <ul>
98
// <li> Elements in a numpy array are called array scalars. They do not have
99
// a python type such as <src>int</src>, but instead a type as
100
// <src>numpy.int32</src>.
101
// The converters can handle such types and convert them correctly to
102
// a scalar.
103
// <li> A numpy scalar array (e.g. <src>array(1.0)</src> is a somewhat
104
// peculiar numpy object. It has an empty shape and cannot be indexed.
105
// It is handled correctly by the from converters and handled as a
106
// scalar value.
107
// <li> An empty numpy object (e.g. <src>array([])</src>) is handled as
108
// a None value.
109
// </ul>
110
// </synopsis>
111
112
// </module>
113
114
}
// namespace casacore
115
116
#endif
casacore
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition
mainpage.dox:28
Generated by
1.15.0