Re: [Numpy-discussion] How to call import_array() properly?

2010-12-27 Thread Bruce Sherwood
The module I'm working with, which uses Boost, doesn't have a function "initcvisual". Rather there's a section headed with BOOST_PYTHON_MODULE( cvisual). Placing the import_array macro directly in this section causes an unwanted return. I guess it doesn't matter, since what I've done works okay. A

Re: [Numpy-discussion] Installing on CentOS 5 claims invalid Python installation

2010-12-27 Thread Roger Martin
Hi Bruce and Chris, This was a user build and install of Python (particularly 2.6.6 since 2.7.1 has build troubles on CentOS 5). The original python 2.4 in the system is ignored for this effort because I can't get to it. Since I was unfamiliar with building Python from source I didn't know i

Re: [Numpy-discussion] How to call import_array() properly?

2010-12-27 Thread Robert Kern
On Mon, Dec 27, 2010 at 13:09, Bruce Sherwood wrote: > Thanks for the good suggestion. I now see that it was purely > historical that import_array was driven (indirectly through > init_numpy) from the pure Python component of the module rather than > in the import of the C++ component, and I've ch

[Numpy-discussion] Strange problem with h5py and numpy

2010-12-27 Thread Johannes Korn
Hi, I have a strange problem with h5py or with numpy. I try to read a bunch of hdf files in a loop. The problem is that I get an error at the second file because the file handle is of type It seems the file is opened and instantaneous closed again. Meanwhile I found the root of the evil: Firs

Re: [Numpy-discussion] How construct custom slice

2010-12-27 Thread Mario Moura
Hi Mr. Goodman Thanks a lot. Works Fine Reagards Mario Moura 2010/12/27 Keith Goodman : > On Mon, Dec 27, 2010 at 10:36 AM, Mario Moura wrote: >> Hi Folks >> >> a = np.zeros((4,3,5,55,5),dtype='|S8') >> myLen = 4 # here I use myLen = len(something) >> li = [3,2,4] # li from a list.append(somet

Re: [Numpy-discussion] How construct custom slice

2010-12-27 Thread Keith Goodman
On Mon, Dec 27, 2010 at 10:36 AM, Mario Moura wrote: > Hi Folks > > a = np.zeros((4,3,5,55,5),dtype='|S8') > myLen = 4 # here I use myLen = len(something) > li = [3,2,4] # li from a list.append(something) > sl = slice(0,myLen) > tmpIndex = tuple(li) + sl + 4  # <== Here my problem > a[tmpIndex] >

[Numpy-discussion] How construct custom slice

2010-12-27 Thread Mario Moura
Hi Folks a = np.zeros((4,3,5,55,5),dtype='|S8') myLen = 4 # here I use myLen = len(something) li = [3,2,4] # li from a list.append(something) sl = slice(0,myLen) tmpIndex = tuple(li) + sl + 4 # <== Here my problem a[tmpIndex] # So What I want is: fillMe = np.array(['foo','bar','hello','world'])

Re: [Numpy-discussion] How to call import_array() properly?

2010-12-27 Thread Bruce Sherwood
Thanks for the good suggestion. I now see that it was purely historical that import_array was driven (indirectly through init_numpy) from the pure Python component of the module rather than in the import of the C++ component, and I've changed that. However, I'm still curious as to whether there's a

Re: [Numpy-discussion] How to call import_array() properly?

2010-12-27 Thread Robert Kern
On Sun, Dec 26, 2010 at 17:26, Bruce Sherwood wrote: > In my Python code I have > > import cvisual > cvisual.init_numpy() > > and in my C++ code I have > > void > init_numpy() > { >    import_array(); > } The import_array() call goes into the initialization function for your module, e.g. initcvis

Re: [Numpy-discussion] Optimization suggestion sought

2010-12-27 Thread Enzo Michelangeli
Many thanks to Josef and Justin for their replies. Josef's hint sounds like a good way of reducing peak memory allocation especially when the row size is large, which makes the "for" overhead for each iteration comparatively lower. However, time is still spent in back-and-forth conversions between