]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/python/doc/numpy/reference/dtype.rst
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / python / doc / numpy / reference / dtype.rst
1 dtype
2 =====
3
4 .. contents :: Table of Contents
5
6 A `dtype`_ is an object describing the type of the elements of an ndarray
7
8 .. _dtype: http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html#data-type-objects-dtype
9
10 ``<boost/python/numpy/dtype.hpp>`` contains the method calls necessary to generate a python object equivalent to a numpy.dtype from builtin C++ objects, as well as to create custom dtypes from user defined types
11
12
13 synopsis
14 --------
15
16 ::
17
18 namespace boost
19 {
20 namespace python
21 {
22 namespace numpy
23 {
24
25 class dtype : public object
26 {
27 static python::detail::new_reference convert(object::object_cref arg, bool align);
28 public:
29
30 // Convert an arbitrary Python object to a data-type descriptor object.
31 template <typename T>
32 explicit dtype(T arg, bool align=false);
33
34 // Get the built-in numpy dtype associated with the given scalar template type.
35 template <typename T> static dtype get_builtin();
36
37 // Return the size of the data type in bytes.
38 int get_itemsize() const;
39 };
40
41 }
42 }
43 }
44
45 constructors
46 ------------
47
48 ::
49
50 template <typename T>
51 explicit dtype(T arg, bool align=false)
52
53 :Requirements: ``T`` must be either :
54
55 * a built-in C++ typename convertible to object
56 * a valid python object or convertible to object
57
58 :Effects: Constructs an object from the supplied python object / convertible
59 to object / builtin C++ data type
60
61 :Throws: Nothing
62
63 ::
64
65 template <typename T> static dtype get_builtin();
66
67 :Requirements: The typename supplied, ``T`` must be a builtin C++ type also supported by numpy
68
69 :Returns: Numpy dtype corresponding to builtin C++ type
70
71 accessors
72 ---------
73
74 ::
75
76 int get_itemsize() const;
77
78 :Returns: the size of the data type in bytes.
79
80
81 Example(s)
82 ----------
83
84 ::
85
86 namespace p = boost::python;
87 namespace np = boost::python::numpy;
88
89 np::dtype dtype = np::dtype::get_builtin<double>();
90 p::tuple for_custom_dtype = p::make_tuple("ha",dtype);
91 np::dtype custom_dtype = np::dtype(list_for_dtype);
92