is there a C-API function for numpy which implements Python's
multidimensional indexing? Say, I have a 2d-array
PyArrayObject * M;
and an index
how do I extract the i-th row or column M[i,:] respectively M[:,i]?
I am looking for a function which gives again a PyArrayObject * and
which is a view to M (no copied data; the result should be another
PyArrayObject whose data and strides points to the correct memory
portion of M).
I searched the API documentation, Google and mailing lists for quite a
long time but didn't find anything. Can you help me?
Hello list.. I've run into two SVD errors over the last few days. Both
errors are identical in numpy/scipy.
I've submitted a ticket for the 1st problem (numpy ticket #990). Summary
is: some builds of the lapack_lite module linking against system LAPACK
(not the bundled dlapack_lite.o, etc) give a "LinAlgError: SVD did not
converge" exception on my matrix. This error does occur using Mac's
Accelerate framework LAPACK, and a coworker's Ubuntu LAPACK version. It
does not seem to happen using ATLAS LAPACK (nor using Octave/Matlab on
Just today I've come across a negative singular value cropping up in an
SVD of a different matrix. This error does occur on my ATLAS LAPACK based
numpy, as well as on the Ubuntu setup. And once again, it does not happen
I'm using numpy 1.3.0.dev6336 -- don't know what the Ubuntu box is running.
Here are some npy files for the two different cases:
I would like to package pyhdf for Ubuntu and make the package publicly
available. Since the license is not totally clear to me (I cannot find any
information in the sources, and the cheeseshop says "public", which
doesn't mean anything to me), I tried to contact the maintainer, Andre
Gosselin, however the email bounces, so I guess he's gone.
Can anyone point me to how to proceed from here?
I've been happy to use numpy.i for generating SWIG interfaces to C++.
For a while, I've noticed this warning while compiling:
warning: #warning "Using deprecated NumPy API, disable it by #defining
and today tried to get rid of the warning.
So, in numpy.i, I followed the warning's advice. I added the # def here:
# define NO_IMPORT_ARRAY
*#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION*
SWIG was happy, but when compiling the C++ wrapper, there were many
warnings followed by many errors. The warnings were for redefinition
of NPY_MIN_BYTE and similar. The errors were for all kinds of stuff,
native_wrap.cpp:3632: error: ‘PyArray_NOTYPE’ was not declared in this scope
native_wrap.cpp:3633: error: cannot convert ‘PyObject*’ to ‘const
PyArrayObject*’ for argument ‘1’ to ‘int PyArray_TYPE(const PyArrayObject*)’
native_wrap.cpp: At global scope:
native_wrap.cpp:3877: error: ‘intp’ has not been declared
native_wrap.cpp: In function ‘int require_fortran(PyArrayObject*)’:
native_wrap.cpp:3929: error: ‘struct tagPyArrayObject’ has no member named
native_wrap.cpp:3933: error: ‘struct tagPyArrayObject’ has no member named
native_wrap.cpp:3933: error: ‘FARRAY’ was not declared in this scope
native_wrap.cpp:20411: error: ‘struct tagPyArrayObject’ has no member named
It looks like there is a new C API for numpy, and the version of numpy.i
that I have doesn't use it.
Is there a new version of numpy.i available (or in development) that works
with the new API? Short term it will just get rid of a warning but I am
interested in a good long term solution in case I need to upgrade numpy.
My question is about reading Fortran binary file (oh no this question
Until now, I was using the unpack module like that :
from struct import unpack
"""Reading a Fortran binary file in litte-endian"""
if fourBeginning: f.seek(4,1)
for array in tuple:
for elt in xrange(array.size):
if fourEnd: f.seek(4,1)
After googling, I read that fopen and npfille was deprecated, and we should
use numpy.fromfile and ndarray.tofile, but despite of the documentaion, the
cookbook, the mailling list and google, I don't succed in making a simple
example. Considering the simple Fortran code below what is the Python script
to read the four arrrays? What about if my pc is little endian and the file
I think it will be a good idea to put the Fortran writting-arrays code and
the Python reading-array script in the cookbook and maybe a page to help
people comming from Fortran to start with Python ?
integer :: i,j
do i = 1,nx
do j = 1,ny
ux(i,j) = real(i*j)
uy(i,j) = real(i)/real(j)
p (i,j) = real(i) + real(j)
end program makeArray
I'm looking for a way to "reduce" dtype1 into dtype2 (when it is possible of course).
Is there some easy way to do that by any chance ?
dtype1 = np.dtype( [ ('vertex', [('x', 'f4'),
('normal', [('x', 'f4'),
('color', [('r', 'f4'),
('a', 'f4')]) ] )
dtype2 = np.dtype( [ ('vertex', 'f4', 3),
('normal', 'f4', 3),
('color', 'f4', 4)] )