Re: [Numpy-discussion] Array vectorization in numpy

2011-07-19 Thread Lutz Maibaum
On Jul 19, 2011, at 3:15 PM, Chad Netzer wrote: > %python import timeit import numpy as np > t=timeit.Timer('k = m - 0.5', setup='import numpy as np;m = np.ones([8092,8092],float); k = np.zeros(m.size, m.dtype)') np.mean(t.repeat(repeat=10, number=1)) > 0.5855752944946288

Re: [Numpy-discussion] Is there a memory-efficient alternative to choose?

2011-03-08 Thread Lutz Maibaum
On Mar 8, 2011, at 11:56 AM, Josh Hykes wrote: > At some point in my code, I need to do a cell-wise multiplication of the > properties with a state variable. The ideal method would (1) be fast (no > Python loops) and (2) not waste memory constructing an entire property map. > My best attempt usi

Re: [Numpy-discussion] How to import input data to make ndarray for batch processing?

2010-11-18 Thread Lutz Maibaum
On Nov 18, 2010, at 6:49 AM, Venkat wrote: > I am trying to reshape my text data which is in one single column (10,000 > rows). > I want the data to be in 100x100 array form. If all you want to do is converting the actual files, and you are using a unix-ish operating system, you don't even need

[Numpy-discussion] Running tests that are marked as KNOWNFAIL

2010-10-25 Thread Lutz Maibaum
Is there a way to execute tests even if they are marked as KNOWNFAIL? For example, the module scipy.sparse.linalg has a few tests that are marked as such on my architecture (OS-X 64 bit). Running scipy.sparse.linalg(extra_argv=["--no-knownfail"]) changes the test result to ERROR, but it looks

Re: [Numpy-discussion] Count occurrences in a nested ndarray

2010-10-19 Thread Lutz Maibaum
On Oct 19, 2010, at 6:09 PM, Dewald Pieterse wrote: > for xiter in range(xindex): > for yiter in range(yindex): > if edges[xiter,yiter,:] == [255,0,0]: > groenpixelarea = groenpixelarea + 1 > if edges[xiter,yiter,:] == [0,255,0]: >

[Numpy-discussion] ndarray.copy does not accept keyword argument

2010-08-12 Thread Lutz Maibaum
According to the docstring, ndarray.copy should accept a keyword argument "order". This doesn't seem to work for me: >>> np.array([[1,2],[3,4]]).copy(order='C') Traceback (most recent call last): File "", line 1, in TypeError: copy() takes no keyword arguments Calling ndarray.copy with a posi

[Numpy-discussion] Converting None to NULL using ndpointer

2010-05-18 Thread Lutz Maibaum
Hello, I am trying to use a C library function from Python using numpy and ctypes. Assume the function has the signature void foo(int* bar) so it usually takes an integer array as a parameter. In python, I define foo.argtypes=[ndpointer(dtype="intc",flags="C_CONTIGUOUS")] and can then call the

Re: [Numpy-discussion] Normalization of ifft

2009-03-27 Thread Lutz Maibaum
Hi Joe, > Travis has freed his original book and large parts of it (e.g., > the C API docs) are now being incorporated into the > actively-maintained manuals at docs.scipy.org.  Please go there for > the latest docs.  You'll find that the fft section gives the 1/n > formula when discussing ifft.

Re: [Numpy-discussion] Normalization of ifft

2009-03-26 Thread Lutz Maibaum
On Thu, Mar 26, 2009 at 7:02 PM, Gideon Simpson wrote: > I thought it was the same as the MATLAB format: > > http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/fft.html&http://www.google.com/search > ?client=safari&rls=en-us&q=MATLAB+fft&ie=UTF-8&oe=

Re: [Numpy-discussion] Normalization of ifft

2009-03-26 Thread Lutz Maibaum
Hi Michael, > this documentation is saying that the difference between the equations > for the fft and ifft is a factor of 1/n (not the numpy implementations). > if you do > >  output = numpy.ifft( numpy.fft( input ) ) > > and you get output = input, then the normalizations are appropriately > wei

[Numpy-discussion] Normalization of ifft

2009-03-26 Thread Lutz Maibaum
Hello, I just started to use python and numpy for some numerical analysis. I have a question about the definition of the inverse Fourier transform. The user gives the formula (p.180) x[m] = Sum_k X[k] exp(j 2pi k m / n) where X[k] are the Fourier coefficients, and n is the length of the arrays