Mercurial > pytave
annotate octave_to_python.cc @ 146:8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
* exceptions.{cc,h}, octave_to_python.{cc,h}, pytave.cc,
python_to_octave.{cc,h}: Use Octave coding style.
* pytave.py, test/exceptions.py, test/test.py: Use PEP8 coding style.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Tue, 05 Apr 2016 08:08:45 -0700 |
parents | fe783134c61c |
children | a3dc9d24ae38 |
rev | line source |
---|---|
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
1 /* |
139
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
2 |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
3 Copyright (C) 2008 David Grundberg, HÃ¥kan Fors Nilsson |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
4 Copyright (C) 2009 VZLU Prague |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
5 |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
6 This file is part of Pytave. |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
7 |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
8 Pytave is free software: you can redistribute it and/or modify it |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
9 under the terms of the GNU General Public License as published by the |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
10 Free Software Foundation, either version 3 of the License, or (at your |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
11 option) any later version. |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
12 |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
13 Pytave is distributed in the hope that it will be useful, but WITHOUT |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
16 for more details. |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
17 |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
18 You should have received a copy of the GNU General Public License |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
19 along with Pytave; see the file COPYING. If not, see |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
20 <http://www.gnu.org/licenses/>. |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
21 |
b12908ffa6df
maint: Use Octave style for file copyright block, delete editor footer
Mike Miller <mtmiller@octave.org>
parents:
134
diff
changeset
|
22 */ |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
23 |
132
386772f4e12d
Clean up includes thanks to Octave header changes
Mike Miller <mtmiller@octave.org>
parents:
108
diff
changeset
|
24 #if defined (HAVE_CONFIG_H) |
386772f4e12d
Clean up includes thanks to Octave header changes
Mike Miller <mtmiller@octave.org>
parents:
108
diff
changeset
|
25 # include <config.h> |
386772f4e12d
Clean up includes thanks to Octave header changes
Mike Miller <mtmiller@octave.org>
parents:
108
diff
changeset
|
26 #endif |
386772f4e12d
Clean up includes thanks to Octave header changes
Mike Miller <mtmiller@octave.org>
parents:
108
diff
changeset
|
27 |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
28 #include <boost/python.hpp> |
100
ff70627aa203
Undef HAVE_STAT and HAVE_FSTAT consistently through-out all files
David Grundberg <individ@acc.umu.se>
parents:
76
diff
changeset
|
29 |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
30 #include <octave/oct.h> |
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
31 #include <octave/ov.h> |
9 | 32 #include <octave/oct-map.h> |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
33 |
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
34 #include <iostream> |
75
b0991511a16d
a few fixes to numpy support
Jaroslav Hajek <highegg@gmail.com>
parents:
70
diff
changeset
|
35 #include "arrayobjectdefs.h" |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
36 #include "exceptions.h" |
56
43a413b7c151
improve conversions, handle POobject and char arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
50
diff
changeset
|
37 #include "octave_to_python.h" |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
38 |
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
39 using namespace boost::python; |
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
40 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
41 namespace pytave |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
42 { |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
43 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
44 template <class PythonPrimitive, class OctaveBase> |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
45 static void |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
46 copy_octarray_to_pyarrobj (PyArrayObject *pyarr, const OctaveBase& matrix, |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
47 const unsigned int matindex, |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
48 const unsigned int matstride, |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
49 const int dimension, const unsigned int offset) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
50 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
51 unsigned char *ptr = (unsigned char*) PyArray_DATA (pyarr); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
52 if (dimension == PyArray_NDIM (pyarr) - 1) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
53 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
54 // Last dimension, base case |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
55 for (int i = 0; i < PyArray_DIM (pyarr, dimension); i++) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
56 { |
108 | 57 *(PythonPrimitive *)&ptr[offset + i*PyArray_STRIDE (pyarr, dimension)] |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
58 = matrix.elem (matindex + i*matstride); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
59 } |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
60 } |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
61 else |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
62 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
63 for (int i = 0; i < PyArray_DIM (pyarr, dimension); i++) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
64 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
65 copy_octarray_to_pyarrobj<PythonPrimitive, OctaveBase> ( |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
66 pyarr, |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
67 matrix, |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
68 matindex + i*matstride, |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
69 matstride * PyArray_DIM (pyarr, dimension), |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
70 dimension + 1, |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
71 offset + i*PyArray_STRIDE (pyarr, dimension)); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
72 } |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
73 } |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
74 } |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
75 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
76 template <> |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
77 void |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
78 copy_octarray_to_pyarrobj<PyObject *, Cell> (PyArrayObject *pyarr, |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
79 const Cell& matrix, |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
80 const unsigned int matindex, |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
81 const unsigned int matstride, |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
82 const int dimension, |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
83 const unsigned int offset) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
84 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
85 unsigned char *ptr = (unsigned char*) PyArray_DATA (pyarr); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
86 if (dimension == PyArray_NDIM (pyarr) - 1) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
87 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
88 // Last dimension, base case |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
89 for (int i = 0; i < PyArray_DIM (pyarr, dimension); i++) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
90 { |
56
43a413b7c151
improve conversions, handle POobject and char arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
50
diff
changeset
|
91 object pyobj; |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
92 octvalue_to_pyobj (pyobj, matrix.elem (matindex + i*matstride)); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
93 Py_INCREF (pyobj.ptr ()); |
108 | 94 *(PyObject **)&ptr[offset + i*PyArray_STRIDE (pyarr, dimension)] |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
95 = pyobj.ptr (); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
96 } |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
97 } |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
98 else |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
99 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
100 for (int i = 0; i < PyArray_DIM (pyarr, dimension); i++) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
101 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
102 copy_octarray_to_pyarrobj<PyObject *, Cell> ( |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
103 pyarr, |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
104 matrix, |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
105 matindex + i*matstride, |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
106 matstride * PyArray_DIM (pyarr, dimension), |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
107 dimension + 1, |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
108 offset + i*PyArray_STRIDE (pyarr, dimension)); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
109 } |
56
43a413b7c151
improve conversions, handle POobject and char arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
50
diff
changeset
|
110 } |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
111 } |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
112 |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
113 static PyArrayObject * |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
114 createPyArr (const dim_vector& dims, int pyarrtype) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
115 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
116 int len = dims.length (); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
117 npy_intp dimensions[len]; |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
118 for (int i = 0; i < dims.length (); i++) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
119 dimensions[i] = dims(i); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
120 |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
121 return (PyArrayObject *)PyArray_SimpleNew (len, dimensions, pyarrtype); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
122 } |
56
43a413b7c151
improve conversions, handle POobject and char arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
50
diff
changeset
|
123 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
124 template <class PythonPrimitive, class OctaveBase> |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
125 static PyArrayObject * |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
126 create_array (const OctaveBase& octarr, int pyarraytype) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
127 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
128 PyArrayObject *pyarr = createPyArr (octarr.dims (), pyarraytype); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
129 try |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
130 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
131 copy_octarray_to_pyarrobj<PythonPrimitive, OctaveBase> (pyarr, octarr, 0, 1, 0, 0); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
132 } |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
133 catch (const value_convert_exception&) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
134 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
135 Py_DECREF (pyarr); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
136 throw; |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
137 } |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
138 return pyarr; |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
139 } |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
140 |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
141 static PyArrayObject * |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
142 octvalue_to_pyarrobj (const octave_value& matrix) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
143 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
144 if (matrix.is_double_type ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
145 if (matrix.is_complex_type ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
146 return create_array<Complex, ComplexNDArray> (matrix.complex_array_value (), NPY_CDOUBLE); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
147 else if (matrix.is_real_type ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
148 return create_array<double, NDArray> (matrix.array_value (), NPY_DOUBLE); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
149 else |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
150 throw value_convert_exception ("Unknown double matrix type"); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
151 |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
152 if (matrix.is_single_type ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
153 if (matrix.is_complex_type ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
154 return create_array<FloatComplex, FloatComplexNDArray> (matrix.float_complex_array_value (), NPY_CFLOAT); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
155 else if (matrix.is_real_type ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
156 return create_array<float, FloatNDArray> (matrix.float_array_value (), NPY_FLOAT); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
157 else |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
158 throw value_convert_exception ("Unknown float matrix type"); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
159 |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
160 if (matrix.is_int8_type ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
161 return create_array<int8_t, int8NDArray> (matrix.int8_array_value (), NPY_INT8); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
162 if (matrix.is_int16_type ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
163 return create_array<int16_t, int16NDArray> (matrix.int16_array_value (), NPY_INT16); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
164 if (matrix.is_int32_type ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
165 return create_array<int32_t, int32NDArray> (matrix.int32_array_value (), NPY_INT32); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
166 if (matrix.is_int64_type ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
167 return create_array<int64_t, int64NDArray> (matrix.int64_array_value (), NPY_INT64); |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
168 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
169 if (matrix.is_uint8_type ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
170 return create_array<uint8_t, uint8NDArray> (matrix.uint8_array_value (), NPY_UINT8); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
171 if (matrix.is_uint16_type ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
172 return create_array<uint16_t, uint16NDArray> (matrix.uint16_array_value (), NPY_UINT16); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
173 if (matrix.is_uint32_type ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
174 return create_array<uint32_t, uint32NDArray> (matrix.uint32_array_value (), NPY_UINT32); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
175 if (matrix.is_uint64_type ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
176 return create_array<uint64_t, uint64NDArray> (matrix.uint64_array_value (), NPY_UINT64); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
177 |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
178 if (matrix.is_bool_type ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
179 return create_array<bool, boolNDArray> (matrix.bool_array_value (), NPY_BOOL); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
180 if (matrix.is_string ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
181 return create_array<char, charNDArray> (matrix.char_array_value (), NPY_CHAR); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
182 if (matrix.is_cell ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
183 return create_array<PyObject *, Cell> (matrix.cell_value (), NPY_OBJECT); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
184 |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
185 throw value_convert_exception ("Octave matrix type not known, conversion not implemented"); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
186 } |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
187 |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
188 static void |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
189 octvalue_to_pyarr (boost::python::object& py_object, |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
190 const octave_value& octvalue) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
191 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
192 PyArrayObject *pyarr = octvalue_to_pyarrobj (octvalue); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
193 py_object = object (handle<PyObject> ((PyObject *)pyarr)); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
194 } |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
195 |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
196 static void |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
197 octmap_to_pyobject (boost::python::object& py_object, |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
198 const octave_map& map) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
199 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
200 py_object = boost::python::dict (); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
201 string_vector keys = map.keys (); |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
202 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
203 for (octave_idx_type i = 0 ; i < keys.numel (); i++) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
204 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
205 boost::python::object py_val; |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
206 const Cell c = map.contents (keys[i]); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
207 octvalue_to_pyarr (py_val, c); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
208 py_object[keys[i]] = py_val; |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
209 } |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
210 } |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
211 |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
212 void octvalue_to_pyobj (boost::python::object& py_object, |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
213 const octave_value& octvalue) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
214 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
215 if (octvalue.is_undefined ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
216 throw value_convert_exception ( |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
217 "Octave value `undefined'. Can not convert to a Python object"); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
218 else if (octvalue.is_numeric_type () || octvalue.is_string () |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
219 || octvalue.is_cell ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
220 octvalue_to_pyarr (py_object, octvalue); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
221 else if (octvalue.is_map ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
222 octmap_to_pyobject (py_object, octvalue.map_value ()); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
223 else |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
224 throw value_convert_exception ( |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
225 "Conversion from Octave value not implemented"); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
226 } |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
227 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
228 void octlist_to_pytuple (boost::python::tuple& python_tuple, |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
229 const octave_value_list& octave_list) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
230 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
231 boost::python::list seq; |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
232 int length = octave_list.length (); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
233 |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
234 // FIXME: due to bugs in Octave 3.2.3 and earlier, lists returned from |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
235 // eval_string and feval may be padded by trailing undefined values. |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
236 // Fix is already upstream, so this may be eventually removed. |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
237 while (length > 0 && octave_list(length-1).is_undefined ()) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
238 length--; |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
239 |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
240 for (int i = 0; i < length; i++) |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
241 { |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
242 boost::python::object py_object; |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
243 octvalue_to_pyobj (py_object, octave_list(i)); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
244 seq.append (py_object); |
0
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
245 } |
4da14cce0890
First launchpad.net check in.
David Grundberg <c04dgg@cs.umu.se>
parents:
diff
changeset
|
246 |
146
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
247 python_tuple = tuple (seq); |
8e3d06f2f5cf
Use Octave coding style for C++ sources, PEP8 style for Python sources
Mike Miller <mtmiller@octave.org>
parents:
143
diff
changeset
|
248 } |
25 | 249 } |