dev new | 1 Nov 2007 07:22
Picon

how to get/set column

is there a method for numpy arrays and matrices to get/set a particular column

i know that a row can be fetched by mymat[1,:] etc
can this be done for a column
dn

_______________________________________________
Numpy-discussion mailing list
Numpy-discussion <at> scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
Vincent Schut | 1 Nov 2007 08:54
Picon

strange problem compiling against ndarrayobject.h

Hmm, it seems my original message did not come through? Not in gmane, at
least... Well, here's again:

Hi numpy and/or gdal guru's,

I'm suddenly getting into trouble compiling gdal's python extension,
when it includes ndarrayobject.h from numpy. First it complains about my
python not being unicode, though I am sure it is unicode, and then it
bails out with all kinds of errors (see snippet below).
Numpy people, please read on even though this might seem a gdal problem,
because it clearly is numpy related, see the snippet...

I've tried everything I could think of, but to no avail. I hope one of
you can give me a hint, because I'm kind of clueless, and even don't
know in what direction I should search...

Here is a paste from the output from building (python setup.py build) in
the gdal/swig/python dir.

make[2]: Entering directory `/usr/local/src/gdal/swig/python'
python setup.py build
numpy include /usr/lib64/python2.5/site-packages/numpy/core/include
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.5
copying gdal.py -> build/lib.linux-x86_64-2.5
copying ogr.py -> build/lib.linux-x86_64-2.5
copying osr.py -> build/lib.linux-x86_64-2.5
copying gdalconst.py -> build/lib.linux-x86_64-2.5
creating build/lib.linux-x86_64-2.5/osgeo
copying osgeo/gdalnumeric.py -> build/lib.linux-x86_64-2.5/osgeo
copying osgeo/gdalconst.py -> build/lib.linux-x86_64-2.5/osgeo
copying osgeo/__init__.py -> build/lib.linux-x86_64-2.5/osgeo
copying osgeo/osr.py -> build/lib.linux-x86_64-2.5/osgeo
copying osgeo/gdal_array.py -> build/lib.linux-x86_64-2.5/osgeo
copying osgeo/gdal.py -> build/lib.linux-x86_64-2.5/osgeo
copying osgeo/ogr.py -> build/lib.linux-x86_64-2.5/osgeo
running build_ext
building 'osgeo._gdal' extension
C compiler: x86_64-pc-linux-gnu-gcc -pthread -fno-strict-aliasing
-DNDEBUG -fPIC

creating build/temp.linux-x86_64-2.5
creating build/temp.linux-x86_64-2.5/extensions
compile options: '-I../../port -I../../gcore -I../../alg -I../../ogr
-I/usr/lib64/python2.5/site-packages/numpy/core/include
-I/usr/include/python2.5 -c'
x86_64-pc-linux-gnu-gcc: extensions/gdal_wrap.cpp
extensions/gdal_wrap.cpp: In function ‘PyObject*
_wrap_MajorObject_SetMetadata__SWIG_0(PyObject*, PyObject*)’:
extensions/gdal_wrap.cpp:4570: warning: deprecated conversion from
string constant to ‘char*’
x86_64-pc-linux-gnu-g++ -pthread -shared
build/temp.linux-x86_64-2.5/extensions/gdal_wrap.o -L../../.libs -L../..
-L/usr/lib64 -lgdal -lpython2.5 -o build/lib.linux-x86_64-2.5/osgeo/_gdal.so
building 'osgeo._gdalconst' extension
C compiler: x86_64-pc-linux-gnu-gcc -pthread -fno-strict-aliasing
-DNDEBUG -fPIC

compile options: '-I../../port -I../../gcore -I../../alg -I../../ogr
-I/usr/lib64/python2.5/site-packages/numpy/core/include
-I/usr/include/python2.5 -c'
x86_64-pc-linux-gnu-gcc: extensions/gdalconst_wrap.c
x86_64-pc-linux-gnu-gcc -pthread -shared
build/temp.linux-x86_64-2.5/extensions/gdalconst_wrap.o -L../../.libs
-L../.. -L/usr/lib64 -lgdal -lpython2.5 -o
build/lib.linux-x86_64-2.5/osgeo/_gdalconst.so
building 'osgeo._osr' extension
C compiler: x86_64-pc-linux-gnu-gcc -pthread -fno-strict-aliasing
-DNDEBUG -fPIC

compile options: '-I../../port -I../../gcore -I../../alg -I../../ogr
-I/usr/lib64/python2.5/site-packages/numpy/core/include
-I/usr/include/python2.5 -c'
x86_64-pc-linux-gnu-gcc: extensions/osr_wrap.cpp
x86_64-pc-linux-gnu-g++ -pthread -shared
build/temp.linux-x86_64-2.5/extensions/osr_wrap.o -L../../.libs -L../..
-L/usr/lib64 -lgdal -lpython2.5 -o build/lib.linux-x86_64-2.5/osgeo/_osr.so
building 'osgeo._ogr' extension
C compiler: x86_64-pc-linux-gnu-gcc -pthread -fno-strict-aliasing
-DNDEBUG -fPIC

compile options: '-I../../port -I../../gcore -I../../alg -I../../ogr
-I/usr/lib64/python2.5/site-packages/numpy/core/include
-I/usr/include/python2.5 -c'
x86_64-pc-linux-gnu-gcc: extensions/ogr_wrap.cpp
x86_64-pc-linux-gnu-g++ -pthread -shared
build/temp.linux-x86_64-2.5/extensions/ogr_wrap.o -L../../.libs -L../..
-L/usr/lib64 -lgdal -lpython2.5 -o build/lib.linux-x86_64-2.5/osgeo/_ogr.so
building 'osgeo._gdal_array' extension
C compiler: x86_64-pc-linux-gnu-gcc -pthread -fno-strict-aliasing
-DNDEBUG -fPIC

compile options: '-I../../port -I../../gcore -I../../alg -I../../ogr
-I/usr/lib64/python2.5/site-packages/numpy/core/include
-I/usr/include/python2.5 -c'
x86_64-pc-linux-gnu-gcc: extensions/_gdal_array.cpp
In file included from
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/arrayobject.h:14,
                 from extensions/gdal_array.h:10,
                 from extensions/_gdal_array.cpp:33:
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:92:2:
error: #error Must use Python with unicode enabled.
In file included from /usr/include/python2.5/Python.h:62,
                 from extensions/gdal_array.h:16,
                 from extensions/_gdal_array.cpp:33:
/usr/include/python2.5/pyport.h:105:1: warning: "PY_SSIZE_T_MAX" redefined
In file included from
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/arrayobject.h:14,
                 from extensions/gdal_array.h:10,
                 from extensions/_gdal_array.cpp:33:
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:931:1:
warning: this is the location of the previous definition
In file included from /usr/include/python2.5/Python.h:62,
                 from extensions/gdal_array.h:16,
                 from extensions/_gdal_array.cpp:33:
/usr/include/python2.5/pyport.h:107:1: warning: "PY_SSIZE_T_MIN" redefined
In file included from
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/arrayobject.h:14,
                 from extensions/gdal_array.h:10,
                 from extensions/_gdal_array.cpp:33:
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:932:1:
warning: this is the location of the previous definition
In file included from /usr/include/python2.5/Python.h:131,
                 from extensions/gdal_array.h:16,
                 from extensions/_gdal_array.cpp:33:
/usr/include/python2.5/abstract.h:762:1: warning: "PyIndex_Check" redefined
In file included from
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/arrayobject.h:14,
                 from extensions/gdal_array.h:10,
                 from extensions/_gdal_array.cpp:33:
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:937:1:
warning: this is the location of the previous definition
In file included from
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/arrayobject.h:14,
                 from extensions/gdal_array.h:10,
                 from extensions/_gdal_array.cpp:33:
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:919:
error: ‘Py_intptr_t’ does not name a type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:920:
error: ‘Py_uintptr_t’ does not name a type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1012:
error: expected initializer before ‘*’ token
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1013:
error: typedef ‘PyArray_SetItemFunc’ is initialized (use __typeof__ instead)
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1013:
error: ‘PyObject’ was not declared in this scope
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1013:
error: expected primary-expression before ‘,’ token
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1013:
error: expected primary-expression before ‘void’
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1013:
error: expected primary-expression before ‘void’
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1015:
error: ‘npy_intp’ has not been declared
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1015:
error: ‘npy_intp’ has not been declared
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1016:
error: ‘npy_intp’ has not been declared
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1026:
error: ‘npy_intp’ has not been declared
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1026:
error: ‘npy_intp’ has not been declared
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1028:
error: ‘npy_intp’ has not been declared
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1028:
error: ‘npy_intp’ has not been declared
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1029:
error: ‘npy_intp’ has not been declared
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1031:
error: ‘npy_intp’ has not been declared
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1041:
error: ‘npy_intp’ has not been declared
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1043:
error: ‘npy_intp’ has not been declared
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1044:
error: ‘npy_intp’ has not been declared
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1044:
error: ‘npy_intp’ has not been declared
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1046:
error: ‘npy_intp’ has not been declared
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1050:
error: ‘npy_intp’ has not been declared
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1052:
error: ‘npy_intp’ has not been declared
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1053:
error: ‘npy_intp’ has not been declared
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1056:
error: ISO C++ forbids declaration of ‘npy_intp’ with no type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1056:
error: expected ‘;’ before ‘*’ token
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1069:
error: ISO C++ forbids declaration of ‘PyArray_GetItemFunc’ with no type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1069:
error: expected ‘;’ before ‘*’ token
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1070:
error: ISO C++ forbids declaration of ‘PyArray_SetItemFunc’ with no type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1070:
error: expected ‘;’ before ‘*’ token
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1121:
error: ISO C++ forbids declaration of ‘PyObject’ with no type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1121:
error: expected ‘;’ before ‘*’ token
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1171:
error: ‘PyObject_HEAD’ does not name a type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1190:
error: ISO C++ forbids declaration of ‘PyObject’ with no type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1190:
error: expected ‘;’ before ‘*’ token
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1194:
error: ISO C++ forbids declaration of ‘PyObject’ with no type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1194:
error: expected ‘;’ before ‘*’ token
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1203:
error: ISO C++ forbids declaration of ‘PyObject’ with no type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1203:
error: expected ‘;’ before ‘*’ token
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1213:
error: ISO C++ forbids declaration of ‘PyObject_HEAD’ with no type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1214:
error: expected ‘;’ before ‘char’
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1216:
error: ISO C++ forbids declaration of ‘npy_intp’ with no type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1216:
error: expected ‘;’ before ‘*’ token
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1217:
error: ISO C++ forbids declaration of ‘npy_intp’ with no type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1217:
error: expected ‘;’ before ‘*’ token
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1219:
error: ISO C++ forbids declaration of ‘PyObject’ with no type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1219:
error: expected ‘;’ before ‘*’ token
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1229:
error: ISO C++ forbids declaration of ‘PyObject’ with no type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1229:
error: expected ‘;’ before ‘*’ token
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1238:
error: ‘PyObject_HEAD’ does not name a type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1246:
error: ‘PyObject_HEAD’ does not name a type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1249:
error: ‘npy_intp’ does not name a type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1253:
error: ‘PyObject’ has not been declared
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1395:
error: ISO C++ forbids declaration of ‘PyObject_HEAD’ with no type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1396:
error: expected ‘;’ before ‘int’
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1397:
error: ‘npy_intp’ does not name a type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1398:
error: ‘npy_intp’ does not name a type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1399:
error: ‘npy_intp’ does not name a type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1400:
error: ‘npy_intp’ does not name a type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1401:
error: ‘npy_intp’ does not name a type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1402:
error: ‘npy_intp’ does not name a type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1542:
error: ISO C++ forbids declaration of ‘PyObject_HEAD’ with no type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1543:
error: expected ‘;’ before ‘int’
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1544:
error: ‘npy_intp’ does not name a type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1545:
error: ‘npy_intp’ does not name a type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1547:
error: ‘npy_intp’ does not name a type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1596:
error: ISO C++ forbids declaration of ‘PyObject_HEAD’ with no type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1600:
error: expected ‘;’ before ‘int’
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1602:
error: ‘npy_intp’ does not name a type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1604:
error: ‘npy_intp’ does not name a type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1606:
error: ‘npy_intp’ does not name a type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1622:
error: ‘npy_intp’ does not name a type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1624:
error: ISO C++ forbids declaration of ‘PyObject’ with no type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1624:
error: expected ‘;’ before ‘*’ token
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1799:
error: ISO C++ forbids declaration of ‘npy_intp’ with no type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1799:
error: expected ‘;’ before ‘*’ token
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1800:
error: ISO C++ forbids declaration of ‘npy_intp’ with no type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1800:
error: expected ‘;’ before ‘*’ token
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1802:
error: ISO C++ forbids declaration of ‘PyObject’ with no type
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1802:
error: expected ‘;’ before ‘*’ token
In file included from
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1814,
                 from
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/arrayobject.h:14,
                 from extensions/gdal_array.h:10,
                 from extensions/_gdal_array.cpp:33:
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:
In function ‘int _import_array()’:
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:945:
error: ‘PyObject’ was not declared in this scope
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:945:
error: ‘numpy’ was not declared in this scope
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:945:
error: ‘PyImport_ImportModule’ was not declared in this scope
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:946:
error: ‘c_api’ was not declared in this scope
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:948:
error: ‘PyObject_GetAttrString’ was not declared in this scope
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:949:
error: ‘Py_DECREF’ was not declared in this scope
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:950:
error: ‘PyCObject_Check’ was not declared in this scope
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:951:
error: ‘PyCObject_AsVoidPtr’ was not declared in this scope
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:953:
error: ‘Py_DECREF’ was not declared in this scope
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:958:
error: ‘PyExc_RuntimeError’ was not declared in this scope
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:958:
error: ‘PyErr_Format’ was not declared in this scope
In file included from /usr/include/python2.5/Python.h:62,
                 from extensions/gdal_array.h:16,
                 from extensions/_gdal_array.cpp:33:
/usr/include/python2.5/pyport.h: At global scope:
/usr/include/python2.5/pyport.h:97: error: conflicting declaration
‘typedef ssize_t Py_ssize_t’
/usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:930:
error: ‘Py_ssize_t’ has a previous declaration as ‘typedef int Py_ssize_t’
extensions/_gdal_array.cpp: In function ‘void init_gdal_array()’:
extensions/_gdal_array.cpp:118: warning: deprecated conversion from
string constant to ‘char*’
extensions/_gdal_array.cpp: In destructor ‘virtual
NUMPYDataset::~NUMPYDataset()’:
extensions/_gdal_array.cpp:162: error: ‘struct PyArrayObject’ has no
member named ‘ob_refcnt’
extensions/_gdal_array.cpp: In static member function ‘static
GDALDataset* NUMPYDataset::Open(GDALOpenInfo*)’:
extensions/_gdal_array.cpp:382: error: ‘struct PyArrayObject’ has no
member named ‘ob_refcnt’
extensions/_gdal_array.cpp:393: error: ‘struct PyArrayObject’ has no
member named ‘dimensions’
extensions/_gdal_array.cpp:394: error: ‘struct PyArrayObject’ has no
member named ‘strides’
extensions/_gdal_array.cpp:395: error: ‘struct PyArrayObject’ has no
member named ‘dimensions’
extensions/_gdal_array.cpp:396: error: ‘struct PyArrayObject’ has no
member named ‘strides’
extensions/_gdal_array.cpp:397: error: ‘struct PyArrayObject’ has no
member named ‘dimensions’
extensions/_gdal_array.cpp:398: error: ‘struct PyArrayObject’ has no
member named ‘strides’
extensions/_gdal_array.cpp:404: error: ‘struct PyArrayObject’ has no
member named ‘dimensions’
extensions/_gdal_array.cpp:405: error: ‘struct PyArrayObject’ has no
member named ‘strides’
extensions/_gdal_array.cpp:406: error: ‘struct PyArrayObject’ has no
member named ‘dimensions’
extensions/_gdal_array.cpp:407: error: ‘struct PyArrayObject’ has no
member named ‘strides’
extensions/_gdal_array.cpp:418: error: ‘struct PyArrayObject’ has no
member named ‘data’

going on like this for some more, but I hope this suffices...

TIA,
Vincent.

_______________________________________________
Numpy-discussion mailing list
Numpy-discussion <at> scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
Vincent Schut | 1 Nov 2007 09:08
Picon

Re: strange problem compiling against ndarrayobject.h

Hi all,

It appeared to be a gdal issue after all: the arrayobject header file
was being included before the python headers...
Glad it wasn't something like me having borked my numpy build :)

Cheers,
Vincent.

Vincent Schut wrote:
> Hmm, it seems my original message did not come through? Not in gmane, at
> least... Well, here's again:
>
> Hi numpy and/or gdal guru's,
>
> I'm suddenly getting into trouble compiling gdal's python extension,
> when it includes ndarrayobject.h from numpy. First it complains about my
> python not being unicode, though I am sure it is unicode, and then it
> bails out with all kinds of errors (see snippet below).
> Numpy people, please read on even though this might seem a gdal problem,
> because it clearly is numpy related, see the snippet...
>
> I've tried everything I could think of, but to no avail. I hope one of
> you can give me a hint, because I'm kind of clueless, and even don't
> know in what direction I should search...
>
> Here is a paste from the output from building (python setup.py build) in
> the gdal/swig/python dir.
>
> make[2]: Entering directory `/usr/local/src/gdal/swig/python'
> python setup.py build
> numpy include /usr/lib64/python2.5/site-packages/numpy/core/include
> running build
> running build_py
> creating build
> creating build/lib.linux-x86_64-2.5
> copying gdal.py -> build/lib.linux-x86_64-2.5
> copying ogr.py -> build/lib.linux-x86_64-2.5
> copying osr.py -> build/lib.linux-x86_64-2.5
> copying gdalconst.py -> build/lib.linux-x86_64-2.5
> creating build/lib.linux-x86_64-2.5/osgeo
> copying osgeo/gdalnumeric.py -> build/lib.linux-x86_64-2.5/osgeo
> copying osgeo/gdalconst.py -> build/lib.linux-x86_64-2.5/osgeo
> copying osgeo/__init__.py -> build/lib.linux-x86_64-2.5/osgeo
> copying osgeo/osr.py -> build/lib.linux-x86_64-2.5/osgeo
> copying osgeo/gdal_array.py -> build/lib.linux-x86_64-2.5/osgeo
> copying osgeo/gdal.py -> build/lib.linux-x86_64-2.5/osgeo
> copying osgeo/ogr.py -> build/lib.linux-x86_64-2.5/osgeo
> running build_ext
> building 'osgeo._gdal' extension
> C compiler: x86_64-pc-linux-gnu-gcc -pthread -fno-strict-aliasing
> -DNDEBUG -fPIC
>
> creating build/temp.linux-x86_64-2.5
> creating build/temp.linux-x86_64-2.5/extensions
> compile options: '-I../../port -I../../gcore -I../../alg -I../../ogr
> -I/usr/lib64/python2.5/site-packages/numpy/core/include
> -I/usr/include/python2.5 -c'
> x86_64-pc-linux-gnu-gcc: extensions/gdal_wrap.cpp
> extensions/gdal_wrap.cpp: In function ‘PyObject*
> _wrap_MajorObject_SetMetadata__SWIG_0(PyObject*, PyObject*)’:
> extensions/gdal_wrap.cpp:4570: warning: deprecated conversion from
> string constant to ‘char*’
> x86_64-pc-linux-gnu-g++ -pthread -shared
> build/temp.linux-x86_64-2.5/extensions/gdal_wrap.o -L../../.libs -L../..
> -L/usr/lib64 -lgdal -lpython2.5 -o build/lib.linux-x86_64-2.5/osgeo/_gdal.so
> building 'osgeo._gdalconst' extension
> C compiler: x86_64-pc-linux-gnu-gcc -pthread -fno-strict-aliasing
> -DNDEBUG -fPIC
>
> compile options: '-I../../port -I../../gcore -I../../alg -I../../ogr
> -I/usr/lib64/python2.5/site-packages/numpy/core/include
> -I/usr/include/python2.5 -c'
> x86_64-pc-linux-gnu-gcc: extensions/gdalconst_wrap.c
> x86_64-pc-linux-gnu-gcc -pthread -shared
> build/temp.linux-x86_64-2.5/extensions/gdalconst_wrap.o -L../../.libs
> -L../.. -L/usr/lib64 -lgdal -lpython2.5 -o
> build/lib.linux-x86_64-2.5/osgeo/_gdalconst.so
> building 'osgeo._osr' extension
> C compiler: x86_64-pc-linux-gnu-gcc -pthread -fno-strict-aliasing
> -DNDEBUG -fPIC
>
> compile options: '-I../../port -I../../gcore -I../../alg -I../../ogr
> -I/usr/lib64/python2.5/site-packages/numpy/core/include
> -I/usr/include/python2.5 -c'
> x86_64-pc-linux-gnu-gcc: extensions/osr_wrap.cpp
> x86_64-pc-linux-gnu-g++ -pthread -shared
> build/temp.linux-x86_64-2.5/extensions/osr_wrap.o -L../../.libs -L../..
> -L/usr/lib64 -lgdal -lpython2.5 -o build/lib.linux-x86_64-2.5/osgeo/_osr.so
> building 'osgeo._ogr' extension
> C compiler: x86_64-pc-linux-gnu-gcc -pthread -fno-strict-aliasing
> -DNDEBUG -fPIC
>
> compile options: '-I../../port -I../../gcore -I../../alg -I../../ogr
> -I/usr/lib64/python2.5/site-packages/numpy/core/include
> -I/usr/include/python2.5 -c'
> x86_64-pc-linux-gnu-gcc: extensions/ogr_wrap.cpp
> x86_64-pc-linux-gnu-g++ -pthread -shared
> build/temp.linux-x86_64-2.5/extensions/ogr_wrap.o -L../../.libs -L../..
> -L/usr/lib64 -lgdal -lpython2.5 -o build/lib.linux-x86_64-2.5/osgeo/_ogr.so
> building 'osgeo._gdal_array' extension
> C compiler: x86_64-pc-linux-gnu-gcc -pthread -fno-strict-aliasing
> -DNDEBUG -fPIC
>
> compile options: '-I../../port -I../../gcore -I../../alg -I../../ogr
> -I/usr/lib64/python2.5/site-packages/numpy/core/include
> -I/usr/include/python2.5 -c'
> x86_64-pc-linux-gnu-gcc: extensions/_gdal_array.cpp
> In file included from
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/arrayobject.h:14,
>                  from extensions/gdal_array.h:10,
>                  from extensions/_gdal_array.cpp:33:
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:92:2:
> error: #error Must use Python with unicode enabled.
> In file included from /usr/include/python2.5/Python.h:62,
>                  from extensions/gdal_array.h:16,
>                  from extensions/_gdal_array.cpp:33:
> /usr/include/python2.5/pyport.h:105:1: warning: "PY_SSIZE_T_MAX" redefined
> In file included from
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/arrayobject.h:14,
>                  from extensions/gdal_array.h:10,
>                  from extensions/_gdal_array.cpp:33:
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:931:1:
> warning: this is the location of the previous definition
> In file included from /usr/include/python2.5/Python.h:62,
>                  from extensions/gdal_array.h:16,
>                  from extensions/_gdal_array.cpp:33:
> /usr/include/python2.5/pyport.h:107:1: warning: "PY_SSIZE_T_MIN" redefined
> In file included from
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/arrayobject.h:14,
>                  from extensions/gdal_array.h:10,
>                  from extensions/_gdal_array.cpp:33:
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:932:1:
> warning: this is the location of the previous definition
> In file included from /usr/include/python2.5/Python.h:131,
>                  from extensions/gdal_array.h:16,
>                  from extensions/_gdal_array.cpp:33:
> /usr/include/python2.5/abstract.h:762:1: warning: "PyIndex_Check" redefined
> In file included from
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/arrayobject.h:14,
>                  from extensions/gdal_array.h:10,
>                  from extensions/_gdal_array.cpp:33:
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:937:1:
> warning: this is the location of the previous definition
> In file included from
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/arrayobject.h:14,
>                  from extensions/gdal_array.h:10,
>                  from extensions/_gdal_array.cpp:33:
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:919:
> error: ‘Py_intptr_t’ does not name a type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:920:
> error: ‘Py_uintptr_t’ does not name a type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1012:
> error: expected initializer before ‘*’ token
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1013:
> error: typedef ‘PyArray_SetItemFunc’ is initialized (use __typeof__ instead)
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1013:
> error: ‘PyObject’ was not declared in this scope
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1013:
> error: expected primary-expression before ‘,’ token
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1013:
> error: expected primary-expression before ‘void’
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1013:
> error: expected primary-expression before ‘void’
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1015:
> error: ‘npy_intp’ has not been declared
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1015:
> error: ‘npy_intp’ has not been declared
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1016:
> error: ‘npy_intp’ has not been declared
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1026:
> error: ‘npy_intp’ has not been declared
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1026:
> error: ‘npy_intp’ has not been declared
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1028:
> error: ‘npy_intp’ has not been declared
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1028:
> error: ‘npy_intp’ has not been declared
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1029:
> error: ‘npy_intp’ has not been declared
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1031:
> error: ‘npy_intp’ has not been declared
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1041:
> error: ‘npy_intp’ has not been declared
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1043:
> error: ‘npy_intp’ has not been declared
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1044:
> error: ‘npy_intp’ has not been declared
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1044:
> error: ‘npy_intp’ has not been declared
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1046:
> error: ‘npy_intp’ has not been declared
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1050:
> error: ‘npy_intp’ has not been declared
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1052:
> error: ‘npy_intp’ has not been declared
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1053:
> error: ‘npy_intp’ has not been declared
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1056:
> error: ISO C++ forbids declaration of ‘npy_intp’ with no type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1056:
> error: expected ‘;’ before ‘*’ token
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1069:
> error: ISO C++ forbids declaration of ‘PyArray_GetItemFunc’ with no type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1069:
> error: expected ‘;’ before ‘*’ token
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1070:
> error: ISO C++ forbids declaration of ‘PyArray_SetItemFunc’ with no type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1070:
> error: expected ‘;’ before ‘*’ token
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1121:
> error: ISO C++ forbids declaration of ‘PyObject’ with no type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1121:
> error: expected ‘;’ before ‘*’ token
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1171:
> error: ‘PyObject_HEAD’ does not name a type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1190:
> error: ISO C++ forbids declaration of ‘PyObject’ with no type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1190:
> error: expected ‘;’ before ‘*’ token
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1194:
> error: ISO C++ forbids declaration of ‘PyObject’ with no type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1194:
> error: expected ‘;’ before ‘*’ token
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1203:
> error: ISO C++ forbids declaration of ‘PyObject’ with no type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1203:
> error: expected ‘;’ before ‘*’ token
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1213:
> error: ISO C++ forbids declaration of ‘PyObject_HEAD’ with no type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1214:
> error: expected ‘;’ before ‘char’
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1216:
> error: ISO C++ forbids declaration of ‘npy_intp’ with no type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1216:
> error: expected ‘;’ before ‘*’ token
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1217:
> error: ISO C++ forbids declaration of ‘npy_intp’ with no type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1217:
> error: expected ‘;’ before ‘*’ token
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1219:
> error: ISO C++ forbids declaration of ‘PyObject’ with no type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1219:
> error: expected ‘;’ before ‘*’ token
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1229:
> error: ISO C++ forbids declaration of ‘PyObject’ with no type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1229:
> error: expected ‘;’ before ‘*’ token
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1238:
> error: ‘PyObject_HEAD’ does not name a type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1246:
> error: ‘PyObject_HEAD’ does not name a type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1249:
> error: ‘npy_intp’ does not name a type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1253:
> error: ‘PyObject’ has not been declared
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1395:
> error: ISO C++ forbids declaration of ‘PyObject_HEAD’ with no type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1396:
> error: expected ‘;’ before ‘int’
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1397:
> error: ‘npy_intp’ does not name a type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1398:
> error: ‘npy_intp’ does not name a type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1399:
> error: ‘npy_intp’ does not name a type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1400:
> error: ‘npy_intp’ does not name a type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1401:
> error: ‘npy_intp’ does not name a type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1402:
> error: ‘npy_intp’ does not name a type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1542:
> error: ISO C++ forbids declaration of ‘PyObject_HEAD’ with no type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1543:
> error: expected ‘;’ before ‘int’
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1544:
> error: ‘npy_intp’ does not name a type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1545:
> error: ‘npy_intp’ does not name a type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1547:
> error: ‘npy_intp’ does not name a type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1596:
> error: ISO C++ forbids declaration of ‘PyObject_HEAD’ with no type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1600:
> error: expected ‘;’ before ‘int’
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1602:
> error: ‘npy_intp’ does not name a type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1604:
> error: ‘npy_intp’ does not name a type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1606:
> error: ‘npy_intp’ does not name a type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1622:
> error: ‘npy_intp’ does not name a type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1624:
> error: ISO C++ forbids declaration of ‘PyObject’ with no type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1624:
> error: expected ‘;’ before ‘*’ token
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1799:
> error: ISO C++ forbids declaration of ‘npy_intp’ with no type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1799:
> error: expected ‘;’ before ‘*’ token
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1800:
> error: ISO C++ forbids declaration of ‘npy_intp’ with no type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1800:
> error: expected ‘;’ before ‘*’ token
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1802:
> error: ISO C++ forbids declaration of ‘PyObject’ with no type
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1802:
> error: expected ‘;’ before ‘*’ token
> In file included from
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:1814,
>                  from
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/arrayobject.h:14,
>                  from extensions/gdal_array.h:10,
>                  from extensions/_gdal_array.cpp:33:
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:
> In function ‘int _import_array()’:
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:945:
> error: ‘PyObject’ was not declared in this scope
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:945:
> error: ‘numpy’ was not declared in this scope
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:945:
> error: ‘PyImport_ImportModule’ was not declared in this scope
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:946:
> error: ‘c_api’ was not declared in this scope
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:948:
> error: ‘PyObject_GetAttrString’ was not declared in this scope
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:949:
> error: ‘Py_DECREF’ was not declared in this scope
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:950:
> error: ‘PyCObject_Check’ was not declared in this scope
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:951:
> error: ‘PyCObject_AsVoidPtr’ was not declared in this scope
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:953:
> error: ‘Py_DECREF’ was not declared in this scope
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:958:
> error: ‘PyExc_RuntimeError’ was not declared in this scope
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:958:
> error: ‘PyErr_Format’ was not declared in this scope
> In file included from /usr/include/python2.5/Python.h:62,
>                  from extensions/gdal_array.h:16,
>                  from extensions/_gdal_array.cpp:33:
> /usr/include/python2.5/pyport.h: At global scope:
> /usr/include/python2.5/pyport.h:97: error: conflicting declaration
> ‘typedef ssize_t Py_ssize_t’
> /usr/lib64/python2.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:930:
> error: ‘Py_ssize_t’ has a previous declaration as ‘typedef int Py_ssize_t’
> extensions/_gdal_array.cpp: In function ‘void init_gdal_array()’:
> extensions/_gdal_array.cpp:118: warning: deprecated conversion from
> string constant to ‘char*’
> extensions/_gdal_array.cpp: In destructor ‘virtual
> NUMPYDataset::~NUMPYDataset()’:
> extensions/_gdal_array.cpp:162: error: ‘struct PyArrayObject’ has no
> member named ‘ob_refcnt’
> extensions/_gdal_array.cpp: In static member function ‘static
> GDALDataset* NUMPYDataset::Open(GDALOpenInfo*)’:
> extensions/_gdal_array.cpp:382: error: ‘struct PyArrayObject’ has no
> member named ‘ob_refcnt’
> extensions/_gdal_array.cpp:393: error: ‘struct PyArrayObject’ has no
> member named ‘dimensions’
> extensions/_gdal_array.cpp:394: error: ‘struct PyArrayObject’ has no
> member named ‘strides’
> extensions/_gdal_array.cpp:395: error: ‘struct PyArrayObject’ has no
> member named ‘dimensions’
> extensions/_gdal_array.cpp:396: error: ‘struct PyArrayObject’ has no
> member named ‘strides’
> extensions/_gdal_array.cpp:397: error: ‘struct PyArrayObject’ has no
> member named ‘dimensions’
> extensions/_gdal_array.cpp:398: error: ‘struct PyArrayObject’ has no
> member named ‘strides’
> extensions/_gdal_array.cpp:404: error: ‘struct PyArrayObject’ has no
> member named ‘dimensions’
> extensions/_gdal_array.cpp:405: error: ‘struct PyArrayObject’ has no
> member named ‘strides’
> extensions/_gdal_array.cpp:406: error: ‘struct PyArrayObject’ has no
> member named ‘dimensions’
> extensions/_gdal_array.cpp:407: error: ‘struct PyArrayObject’ has no
> member named ‘strides’
> extensions/_gdal_array.cpp:418: error: ‘struct PyArrayObject’ has no
> member named ‘data’
>
> going on like this for some more, but I hope this suffices...
>
> TIA,
> Vincent.
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion <at> scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>   

_______________________________________________
Numpy-discussion mailing list
Numpy-discussion <at> scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
bernhard.voigt@gmail.com | 1 Nov 2007 10:09
Picon

Re: how to get/set column

It's just the other way around:
mymat[:,0]  # first column
mymat[:,1]  # second column

Take a look at the tutorial:
http://scipy.org/Tentative_NumPy_Tutorial#head-864862d3f2bb4c32f04260fac61eb4ef34788c4c

best! bernhard

On Nov 1, 7:22 am, "dev new" <dev... <at> gmail.com> wrote:
> is there a method for numpy arrays and matrices to get/set a particular
> column
>
> i know that a row can be fetched by mymat[1,:] etc
> can this be done for a column
> dn
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discuss... <at> scipy.orghttp://projects.scipy.org/mailman/listinfo/numpy-discussion
Francesc Altet | 1 Nov 2007 13:56

Re: vectorizing loops

A Wednesday 31 October 2007, Timothy Hochberg escrigué:
> On Oct 31, 2007 3:18 AM, Francesc Altet <faltet <at> carabos.com> wrote:
>
> [SNIP]
>
> > Incidentally, all the improvements of the PyTables flavor of
> > numexpr have been reported to the original authors, but, for the
> > sake of keeping numexpr simple, they decided to implement only some
> > of them. However, people is encouraged to try out the Pytables
> > flavor from:
>
> My original concern was that we'd start overflowing the code cache
> and slow things down. Some experiments seemed to confirm this on some
> processors, but it then turned out those were in error. At least
> that's my recollection. Because of that, and because PyTables is, as
> far as I know, the major user of numexpr, I suspect I'd be fine
> putting those changes in now. I say "suspect" since it's been a long
> time since I looked at the relevant patches, and I should probably
> look at those again before I commit myself. I just haven't had the
> free time and motivation to go back and look at the patches.  I can't
> speak for David though.

Yes, I remember that you were mainly concerned with overflowing the code 
cache, and yes, I think you can be confident this is not the case, as 
my benchmarking in many CPU's (ranging from 7 year old AMD Duron, 
Pentiums 4 and up to relatively recents AMD Opterons), doesn't show any 
slow down with the PyTables version of numexpr, but rather the 
contrary, it speeds things up, specially in contexts where booleans 
and/or strided/unaligned arrays are used, where the improvement can be 
up to 2x on recent CPU's (as shown in my previous post).

If I remember correctly, another point where you (specially David) were 
not very keen to include was the support for strings, arguing that 
numexpr is meant mainly to deal with numerical data, not textual.  
However, our experience is that adding this support was not too 
complicated (mainly due to NumPy flexibility), and can be helpful in 
some instances.  As for one, we use them for evaluating expressions 
like 'array_string == "some_string"', and this can be very convenient 
to use when you are in the middle of potentially complex boolean 
expressions that you want to evaluate *fast*.

At any rate, we would be glad if you would like to integrate our patches 
in the main numexpr, as there is not much sense to have different 
implementations of numexpr (most specially when it seems that there are 
not much users out there).  So, count on us for any question you may 
have in this regard.

Cheers,

--

-- 
>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data
 "-"
David M. Cooke | 1 Nov 2007 15:14
Picon
Picon

Re: vectorizing loops

On Nov 1, 2007, at 08:56 , Francesc Altet wrote:

> A Wednesday 31 October 2007, Timothy Hochberg escrigué:
>> On Oct 31, 2007 3:18 AM, Francesc Altet <faltet <at> carabos.com> wrote:
>>
>> [SNIP]
>>
>>> Incidentally, all the improvements of the PyTables flavor of
>>> numexpr have been reported to the original authors, but, for the
>>> sake of keeping numexpr simple, they decided to implement only some
>>> of them. However, people is encouraged to try out the Pytables
>>> flavor from:
>>
>> My original concern was that we'd start overflowing the code cache
>> and slow things down. Some experiments seemed to confirm this on some
>> processors, but it then turned out those were in error. At least
>> that's my recollection. Because of that, and because PyTables is, as
>> far as I know, the major user of numexpr, I suspect I'd be fine
>> putting those changes in now. I say "suspect" since it's been a long
>> time since I looked at the relevant patches, and I should probably
>> look at those again before I commit myself. I just haven't had the
>> free time and motivation to go back and look at the patches.  I can't
>> speak for David though.
>
> If I remember correctly, another point where you (specially David)  
> were
> not very keen to include was the support for strings, arguing that
> numexpr is meant mainly to deal with numerical data, not textual.
> However, our experience is that adding this support was not too
> complicated (mainly due to NumPy flexibility), and can be helpful in
> some instances.  As for one, we use them for evaluating expressions
> like 'array_string == "some_string"', and this can be very convenient
> to use when you are in the middle of potentially complex boolean
> expressions that you want to evaluate *fast*.
>
> At any rate, we would be glad if you would like to integrate our  
> patches
> in the main numexpr, as there is not much sense to have different
> implementations of numexpr (most specially when it seems that there  
> are
> not much users out there).  So, count on us for any question you may
> have in this regard.

Well, I don't have much time to work on it, but if you make sure your  
patches on the scipy Trac apply clean, I'll have a quick look at them  
and apply them. Since you've had them working in production code, they  
should be good ;-)

Another issue is that numexpr is still in the scipy sandbox, so only  
those who enable it will use it (or use it through PyTables). One  
problem with moving it out is that Tim reports the compile times on  
Windows are ridiculous (20 mins!). Maybe numexpr should become a  
scikit? It certainly doesn't need the rest of scipy.

--

-- 
|>|\/|<
/------------------------------------------------------------------\
|David M. Cooke              http://arbutus.physics.mcmaster.ca/dmc/
|cookedm <at> physics.mcmaster.ca
Ray Schumacher | 1 Nov 2007 15:56
Favicon

Re: numpy FFT memory accumulation

At 11:55 PM 10/31/2007, Travis wrote:
>Ray S wrote:
> > I am using
> > fftRes = abs(fft.rfft(data_array[end-2**15:end]))
> >
>At first glance, I would say that I don't expect memory to be growing
>here, so it looks like a problem with rfft that deserves looking into.

I saw that Numeric did also (I still use Numeric for smaller array 
speed) but much more slowly.
I will try to repeat with a small demo and post.

>Does data_array keep growing?

no, it is a 64k circular buffer
Which reminds me, I've been wanting to try to build a Numeric 
circular buffer object; one that, when sliced or assigned to, 
auto-magically wraps as needed, exposing only an extra pointer 
attribute for the "end". I currently always do it with Python if-s 
and pointer vars for these products that only do "real time" data analysis.

>From: "Anne Archibald" <peridot.faceted <at> gmail.com>
>If the range is *really* small, you can try using a DFT - sometimes
>that is fast enough, and gives you just the bins you're curious about.

I've considered weave'ing a simple sine transform with specified 
range, but until I do and test I won't know if my own implementation 
is any faster than just the FFTPACK.

>If the range is bigger than that, but still a small fraction of the
>FFT size, you can do some tricks where you band-pass filter the data
>...
>There are also "zoom fft" and "chirp-z" techniques which are supposed
>to give you only part of the FFT, but the wisdom is that unless you
>want less than a few percent of the data points you're better just
>FFTing and throwing lots of data away.

I've tried zoom before; the issue was just that - 2 FFTs and a shift 
or convolution eats a lot of CPU cycles and falls behind the real 
time data. The range of interest in the Fourrier domain is small, 
3kHz-7kHz. The sample rate is high for precise phase information.
I've got some more testing to do, it seems.

Thanks,
Ray

--

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.15.15/1101 - Release Date: 10/31/2007 10:06 AM
Charles R Harris | 1 Nov 2007 16:18
Picon

Re: numpy FFT memory accumulation



On 11/1/07, Ray Schumacher <subscriber100 <at> rjs.org> wrote:
> At 11:55 PM 10/31/2007, Travis wrote:
> >Ray S wrote:
> > > I am using
> > > fftRes = abs( fft.rfft(data_array[end-2**15:end]))
> > >
> >At first glance, I would say that I don't expect memory to be growing
> >here, so it looks like a problem with rfft that deserves looking into.
>
> I saw that Numeric did also (I still use Numeric for smaller array
> speed) but much more slowly.
> I will try to repeat with a small demo and post.
>
> >Does data_array keep growing?
>
> no, it is a 64k circular buffer
> Which reminds me, I've been wanting to try to build a Numeric
> circular buffer object; one that, when sliced or assigned to,
> auto-magically wraps as needed, exposing only an extra pointer
> attribute for the "end". I currently always do it with Python if-s
> and pointer vars for these products that only do "real time" data analysis.
>

In Python, collections.deque makes a pretty good circular buffer. Numpy will make an array out of it, which involves a copy, but it might be better than what you are doing now.

In [14]: from collections import deque

In [15]: a = deque([1,2,3,4])

In [16]: fft(a)
Out[16]: array([ 10.+0.j,  -2.+2.j,  -2.+0.j,  -2.-2. j])

In [17]: a.append(5)

In [18]: a.popleft()
Out[18]: 1

In [19]: fft(a)
Out[19]: array([ 14.+0.j,  -2.+2.j,  -2.+0.j,  -2.- 2.j])


Chuck

_______________________________________________
Numpy-discussion mailing list
Numpy-discussion <at> scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
Ray S | 1 Nov 2007 20:16
Favicon

Re: numpy FFT memory accumulation

At 09:00 AM 11/1/2007, Chuck wrote:

In Python, collections.deque makes a pretty good circular buffer. 
Numpy will
make an array out of it, which involves a copy, but it might be 
better than what you are doing now.

hmmm, I'll think more about that - and the copy is only at program 
start, it seems
the fft can always be fft(d[:-N])
 >>> from collections import deque
 >>> import numpy as N
 >>> d = deque(N.zeros(10,))
 >>> d.extend(N.ones(4,))
 >>> d
deque([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 
1.0, 1.0])
 >>> [d.pop() for i in range(4)]
[1.0, 1.0, 1.0, 1.0]
 >>> d
deque([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])

An additional complication is that I pass the numpy (or Numeric) 
array address to the ctypes library call so that the data is placed 
directly into the array from the call. I use the if/else end wrap 
logic to determine whether I need to do a split and copy if the new 
data wraps.

Thanks,
Ray
Ray S | 1 Nov 2007 20:38
Favicon

Re: numpy FFT memory accumulation

At 09:00 AM 11/1/2007, you wrote:
I saw that Numeric did also (I still use Numeric for smaller array
speed) but much more slowly.
I will try to repeat with a small demo and post.

It turns out to be some aspect of mixing numpy and Numeric;

the attached *Stable.py files allocate memory that stays exactly the 
same

mixedGrows.py grows by about 50kB/s while changing slightly, 
randomly; note that the array is assigned as numpy and operated on 
with Numeric functions.

My main app also uses mmap/numpy to assign the arrays to shared 
memory for multiple processes, and does other operations as well, 
possibly accounting for the faster memory growth.
I'll re-factor to an all-numpy solution and test.

I used Numeric functions for the ~40% speed increase, but I don't 
have a compiled version of arrayfrombuffer() for Numeric
http://www.canonical.org/~kragen/sw/arrayfrombuffer/ (compiler 
version woes)
so, I must use numpy.frombuffer() with mmap to create the shared 
arrays...

Ray
import numpy
import numpy.fft as fft

CIRC_BUFFER_SIZE = 2**16
LARGE_FFT_SIZE = 2048*8
numpy.random.seed()

dataArray = numpy.zeros((CIRC_BUFFER_SIZE*2,), numpy.int32)
while 1:
    fftArray = abs(fft.rfft(dataArray[:LARGE_FFT_SIZE]))
    fftArray[:-1] = fftArray[1:] ## shift the bins lose the DC
    maxBin = numpy.argmax(fftArray[1000:5000])+1000
    print "\r%d" % (maxBin),
    dataArray[0:CIRC_BUFFER_SIZE] = numpy.random.binomial(5000000, .5, (CIRC_BUFFER_SIZE,))

import RandomArray
import Numeric
import FFT

CIRC_BUFFER_SIZE = 2**16
LARGE_FFT_SIZE = 2048*8
RandomArray.seed()

def freqAnalysis():
    global infoArray,dataArray
    fftArray = abs(FFT.real_fft(dataArray[:LARGE_FFT_SIZE]))
    maxBin = Numeric.argmax(fftArray[1000:5000])+1000
    return maxBin

def getMoreData():
    global infoArray,dataArray
    dataArray[0:CIRC_BUFFER_SIZE] = RandomArray.binomial(5000000, .5, (CIRC_BUFFER_SIZE,))

## small array to hold shared variables
## 0 -> bufferInsertPos ## 1 -> dataTotSamples
## 2 -> sampPerRot ## 3 -> run signal
infoArray = Numeric.zeros((4,), Numeric.Float32)
dataArray = Numeric.zeros((CIRC_BUFFER_SIZE*2,), Numeric.Int32)
while 1:
    infoArray[2] = freqAnalysis() ## sampPerRot
    print "\r%d" % (infoArray[2]),
    getMoreData()

import RandomArray
import Numeric
import FFT
import mmap
import numpy

CIRC_BUFFER_SIZE = 2**16
LARGE_FFT_SIZE = 2048*8
RandomArray.seed()

dataArray = numpy.zeros((CIRC_BUFFER_SIZE*2,), numpy.int32)
while 1:
    fftArray = abs(FFT.real_fft(dataArray[:LARGE_FFT_SIZE]))
    fftArray[:-1] = fftArray[1:] ## shift the bins lose the DC
    maxBin = Numeric.argmax(fftArray[1000:5000])+1000
    print "\r%d" % (maxBin),
    dataArray[0:CIRC_BUFFER_SIZE] = RandomArray.normal(5000000, 2000000, (CIRC_BUFFER_SIZE,))

_______________________________________________
Numpy-discussion mailing list
Numpy-discussion <at> scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Gmane