[Numpy-discussion] setmember1d_nu
Hi all, I have added to the ticket [1] a script that compares the proposed setmember1d_nu() implementations of Neil and Kim. Comments are welcome! [1] http://projects.scipy.org/numpy/ticket/1036 r. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] numpy-svn mails
Hi, Is anyone getting mails of the SVN commits? I've gotten 1 spam message from that list, but no commits. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Interpolation via Fourier transform
I found the solution I needed for my peculiar case after reading your email based of the following stages: I have a N x N frequency-domain matrix Z 1. Use fftshift to obtain a DC centered matrix Note: fftshift(fft(a)) replaces np.fft.fft(np.power(-1,np.arange(64))*a) Zs = np.fft.fftshift(Z) 2. pad Zs with zeros scale = int(ceil(float(N)/M)) MM = scale*M Ztemp = np.zeros((MM,MM), dtype=complex) Ztemp[(MM-N)//2:(N-MM)//2,(MM-N)//2:(N-MM)//2] = Zs 3. Shift back to a normal order Ztemp = np.fft.ifftshift(Ztemp) 4. Transform to the time domain and sub-sample z = np.fft.ifft2(Ztemp)[::scale, ::scale] I went this was since I needed the aliasing, otherwise I could just truncate Zs to size MxM. Thank you, Nadav. -הודעה מקורית- מאת: numpy-discussion-boun...@scipy.org בשם M Trumpis נשלח: ה 05-מרץ-09 21:51 אל: Discussion of Numerical Python נושא: Re: [Numpy-discussion] Interpolation via Fourier transform Hi Nadav.. if you want a lower resolution 2d function with the same field of view (or whatever term is appropriate to your case), then in principle you can truncate your higher frequencies and do this: sig = ifft2_func(sig[N/2 - M/2:N/2 + M/2, N/2 - M/2:N/2+M/2]) I like to use an fft that transforms from an array indexing negative-to-positive freqs to an array that indexes negative-to-positive spatial points, so in both spaces, the origin is at (N/2,N/2). Then the expression works as-is. The problem is if you've got different indexing in one or both spaces (typically positive frequencies followed by negative) you can play around with a change of variables in your DFT in one or both spaces. If the DFT is defined as a computing frequencies from 0,N, then putting in n' = n-N/2 leads to a term like exp(1j*pi*q) that multiplies f[q]. Here's a toy example: a = np.cos(2*np.pi*5*np.arange(64)/64.) P.plot(np.fft.fft(a).real) P.plot(np.fft.fft(np.power(-1,np.arange(64))*a).real) The second one is centered about index N/2 Similarly, if you need to change the limits of the summation of the DFT from 0,N to -N/2,N/2, then you can multiply exp(1j*pi*n) to the outside of the summation. Like I said, easy enough in principle! Mike On Thu, Mar 5, 2009 at 11:02 AM, Nadav Horesh nad...@visionsense.com wrote: I apology for this off topic question: I have a 2D FT of size N x N, and I would like to reconstruct the original signal with a lower sampling frequency directly (without using an interpolation procedure): Given M N the goal is to compute a M x M time domain signal. In the case of 1D signal the trick is simple --- given a length N freq. domain Sig: sig = np.fft.ifft(Sig, M) This trick does not work in 2D: sig = np.fft.ifft2(Sig, (M,M)) is far from being the right answer. Any ideas? ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion winmail.dat___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] N-D array interface page is out of date
Hi, I have updated http://numpy.scipy.org/array_interface.shtml to have a giant warning first paragraph describing how that information is outdated. Additionally, I have updated http://numpy.scipy.org/ to point people to the buffer interface described in PEP 3118 and implemented in Python 2.6/3.0. Furthermore, I have suggested Cython has a way to write code for older Pythons that will automatically support the buffer interface in newer Pythons. If you have knowledge about these matters (Travis O. and Dag, especially), I'd appreciate it if you could read over the pages to ensure everything is actually correct. Thanks, Andrew Stéfan van der Walt wrote: 2009/2/3 Andrew Straw straw...@astraw.com: Can someone with appropriate permissions fix the page or give me the appropriate permissions so I can do it? I think even deleting the page is better than keeping it as-is. Who all has editing access to this page? Is it hosted on scipy.org? Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Interpolation via Fourier transform
Hi Nadav You can also read the interesting discussion at http://projects.scipy.org/numpy/ticket/748 which also contains some padding code. I still disagree with the conclusion, but oh well :) Cheers Stéfan 2009/3/6 Nadav Horesh nad...@visionsense.com: I found the solution I needed for my peculiar case after reading your email based of the following stages: I have a N x N frequency-domain matrix Z 1. Use fftshift to obtain a DC centered matrix Note: fftshift(fft(a)) replaces np.fft.fft(np.power(-1,np.arange(64))*a) Zs = np.fft.fftshift(Z) 2. pad Zs with zeros scale = int(ceil(float(N)/M)) MM = scale*M Ztemp = np.zeros((MM,MM), dtype=complex) Ztemp[(MM-N)//2:(N-MM)//2,(MM-N)//2:(N-MM)//2] = Zs 3. Shift back to a normal order Ztemp = np.fft.ifftshift(Ztemp) 4. Transform to the time domain and sub-sample z = np.fft.ifft2(Ztemp)[::scale, ::scale] I went this was since I needed the aliasing, otherwise I could just truncate Zs to size MxM. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Interpolation via Fourier transform
It was one of the first things I tried, without success Nadav. -הודעה מקורית- מאת: numpy-discussion-boun...@scipy.org בשם Anne Archibald נשלח: ה 05-מרץ-09 22:06 אל: Discussion of Numerical Python נושא: Re: [Numpy-discussion] Interpolation via Fourier transform 2009/3/5 M Trumpis mtrum...@berkeley.edu: Hi Nadav.. if you want a lower resolution 2d function with the same field of view (or whatever term is appropriate to your case), then in principle you can truncate your higher frequencies and do this: sig = ifft2_func(sig[N/2 - M/2:N/2 + M/2, N/2 - M/2:N/2+M/2]) I like to use an fft that transforms from an array indexing negative-to-positive freqs to an array that indexes negative-to-positive spatial points, so in both spaces, the origin is at (N/2,N/2). Then the expression works as-is. The problem is if you've got different indexing in one or both spaces (typically positive frequencies followed by negative) you can play around with a change of variables in your DFT in one or both spaces. If the DFT is defined as a computing frequencies from 0,N, then putting in n' = n-N/2 leads to a term like exp(1j*pi*q) that multiplies f[q]. Here's a toy example: a = np.cos(2*np.pi*5*np.arange(64)/64.) P.plot(np.fft.fft(a).real) P.plot(np.fft.fft(np.power(-1,np.arange(64))*a).real) The second one is centered about index N/2 Similarly, if you need to change the limits of the summation of the DFT from 0,N to -N/2,N/2, then you can multiply exp(1j*pi*n) to the outside of the summation. Like I said, easy enough in principle! There's also the hit-it-with-a-hammer approach: Just downsample in x then in y, using the one-dimensional transforms. Anne ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion winmail.dat___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Cython numerical syntax revisited
Hi, The idea behind the current syntax was to keep things as close as possible to Python/NumPy, and only provide some hints to Cython for optimization. My problem with this now is that a) it's too easy to get non-optimized code without a warning by letting in untyped indices, b) I think the whole thing is a bit too magic and that it is too unclear what is going on to newcomers (though I'm guessing there). My proposal: Introduce an explicit buffer syntax: arr = np.zeros(..) cdef int[:,:] buf = arr # 2D buffer I like this proposal a lot; it seems a great deal clearer to me than the earlier syntax; it helps me think of the new Cython thing that I have in a different and more natural way. Best, Matthew ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Cython numerical syntax revisited
2009/3/5 Francesc Alted fal...@pytables.org: A Thursday 05 March 2009, Francesc Alted escrigué: Well, I suppose that, provided that Cython could perform the for-loop transformation, giving support for strided arrays would be relatively trivial, and the performance would be similar than numexpr in this case. Mmh, perhaps not so trivial, because that implies that the stride of an array should be known in compilation time, and that would require a new qualifier when declaring the array. Tricky... Not necessarily. You can transform a[1,2,3] into *(a.data + 1*a.strides[0] + 2*a.strides[1] + 3*a.strides[2]) without any need for static information beyond that a is 3-dimensional. This would already be valuable, though perhaps you'd want to be able to declare that a particular dimension had stride 1 to simplify things. You could then use this same implementation to add automatic iteration. Anne Cheers, -- Francesc Alted ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy-svn mails
On Fri, Mar 6, 2009 at 8:28 AM, Ryan May rma...@gmail.com wrote: Hi, Is anyone getting mails of the SVN commits? I've gotten 1 spam message from that list, but no commits. Ryan I'm not seeing them either...Chuck ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy-svn mails
On Mar 6, 2009, at 12:46 PM, Charles R Harris wrote: On Fri, Mar 6, 2009 at 8:28 AM, Ryan May rma...@gmail.com wrote: Hi, Is anyone getting mails of the SVN commits? I've gotten 1 spam message from that list, but no commits. Ryan I'm not seeing them either...Chuck Hey guys, I'm working on this problem now. You might see a spurious email here or there, and I will let everyone know on both scipy and numpy lists when they are going again. In the interim, please use Trac to look at checkins: http://projects.scipy.org/numpy/log/ http://projects.scipy.org/scipy/log/ Thanks for your patience, Peter ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Build Failure on WIndows Vista
Greetings, I am running Windows Vista Ultimate and trying to build numpy from the SVN branch using MSVC 2003. I have been able to build previously, but with my latest SVN update I am no longer able to build. My CPU is an Intel Core2 T7600 @2.33GHz. The error is below. e:\svn\numpy\numpy\core\include\numpy\npy_cpu.h(44) : fatal error C1189: #error: Unknown CPU, please report this to numpy maintainers with information about your platform (OS, CPU and compiler) error: Command D:\Program Files\Microsoft Visual Studio 2003\bin\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -Inumpy\core\include -Ibuild\src.win32-2.5\numpy\core\include/numpy -Inumpy\core\src -Inumpy\core\include -ID:\Python25\include -ID:\Python25\PC /Tcbuild\src.win32-2.5\numpy\core\src\_sortmodule.c /Fobuild\temp.win32-2.5\Release\build\src.win32-2.5\numpy\core\src\_sortmodule.obj failed with exit status 2 -Patrick -- Patrick Marsh Graduate Research Assistant School of Meteorology University of Oklahoma http://www.patricktmarsh.com ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Changeset 6557
Hi David, Currently, bint.i = __STR2INTCST(ABCD); It is probably more portable to just initialize the union union { char c[4]; npy_uint32 i; } bint = {'A','B','C','D'}; If you use const union the initialization will be done at compile time. Chuck ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Changeset 6557
On Fri, Mar 6, 2009 at 2:01 PM, Charles R Harris charlesr.har...@gmail.comwrote: Hi David, Currently, bint.i = __STR2INTCST(ABCD); It is probably more portable to just initialize the union union { char c[4]; npy_uint32 i; } bint = {'A','B','C','D'}; If you use const union the initialization will be done at compile time. Better yet const union { npy_uint32 i; char c[4]; } bint = {0x01020304}; And check for the numbers 1,2,3,4. Chuck ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] can't take FFT of ndarray
Hi there - I've imported some data from a file, and it's in a list called mixfrac. I'd like to take the Fourier transform of the data, but when I try to take the FFT of the list, I get this error: --- TypeError Traceback (most recent call last) /Users/charles/apriori/read.py in module() 1 2 3 4 5 /Library/Python/2.5/site-packages/numpy-1.3.0.dev5825-py2.5-macosx-10.3-i386.egg/numpy/fft/fftpack.pyc in fft(a, n, axis) 105 106 -- 107 return _raw_fft(a, n, axis, fftpack.cffti, fftpack.cfftf, _fft_cache) 108 109 /Library/Python/2.5/site-packages/numpy-1.3.0.dev5825-py2.5-macosx-10.3-i386.egg/numpy/fft/fftpack.pyc in _raw_fft(a, n, axis, init_function, work_function, fft_cache) 64 if axis != -1: 65 a = swapaxes(a, axis, -1) --- 66 r = work_function(a, wsave) 67 if axis != -1: 68 r = swapaxes(r, axis, -1) TypeError: array cannot be safely cast to required type so I convert to an array and run fft(mixfracarray). mixfracarray = array(mixfrac) fft(mixfracarray) whereupon I recieve the error --- TypeError Traceback (most recent call last) /Users/charles/apriori/read.py in module() 1 2 3 4 5 /Library/Python/2.5/site-packages/numpy-1.3.0.dev5825-py2.5-macosx-10.3-i386.egg/numpy/fft/fftpack.pyc in fft(a, n, axis) 105 106 -- 107 return _raw_fft(a, n, axis, fftpack.cffti, fftpack.cfftf, _fft_cache) 108 109 /Library/Python/2.5/site-packages/numpy-1.3.0.dev5825-py2.5-macosx-10.3-i386.egg/numpy/fft/fftpack.pyc in _raw_fft(a, n, axis, init_function, work_function, fft_cache) 64 if axis != -1: 65 a = swapaxes(a, axis, -1) --- 66 r = work_function(a, wsave) 67 if axis != -1: 68 r = swapaxes(r, axis, -1) TypeError: array cannot be safely cast to required type This is strange, because I can run fft(array([0,0,0,1,1,1])), or fft([0,0,0,1,1,1]), perfectly fine. This is passing an array and a list, respectively. type(mixfrac) is list and size(mixfrac) is 100; type(mixfracarray) is ndarray, and mixfracarray.shape is (100,). I've also tried taking the FFT of the transpose of mixfracarray, but that doesn't work either. I'm stumped - why can't I run an FFT on either mixfrac or mixfracarray? Charles ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] can't take FFT of ndarray
On Fri, Mar 6, 2009 at 3:36 PM, charles reid charlesre...@gmail.com wrote: Hi there - I've imported some data from a file, and it's in a list called mixfrac. I'd like to take the Fourier transform of the data, but when I try to take the FFT of the list, I get this error: --- TypeError Traceback (most recent call last) /Users/charles/apriori/read.py in module() 1 2 3 4 5 /Library/Python/2.5/site-packages/numpy-1.3.0.dev5825-py2.5-macosx-10.3-i386.egg/numpy/fft/fftpack.pyc in fft(a, n, axis) 105 106 -- 107 return _raw_fft(a, n, axis, fftpack.cffti, fftpack.cfftf, _fft_cache) 108 109 /Library/Python/2.5/site-packages/numpy-1.3.0.dev5825-py2.5-macosx-10.3-i386.egg/numpy/fft/fftpack.pyc in _raw_fft(a, n, axis, init_function, work_function, fft_cache) 64 if axis != -1: 65 a = swapaxes(a, axis, -1) --- 66 r = work_function(a, wsave) 67 if axis != -1: 68 r = swapaxes(r, axis, -1) TypeError: array cannot be safely cast to required type so I convert to an array and run fft(mixfracarray). mixfracarray = array(mixfrac) fft(mixfracarray) whereupon I recieve the error --- TypeError Traceback (most recent call last) /Users/charles/apriori/read.py in module() 1 2 3 4 5 /Library/Python/2.5/site-packages/numpy-1.3.0.dev5825-py2.5-macosx-10.3-i386.egg/numpy/fft/fftpack.pyc in fft(a, n, axis) 105 106 -- 107 return _raw_fft(a, n, axis, fftpack.cffti, fftpack.cfftf, _fft_cache) 108 109 /Library/Python/2.5/site-packages/numpy-1.3.0.dev5825-py2.5-macosx-10.3-i386.egg/numpy/fft/fftpack.pyc in _raw_fft(a, n, axis, init_function, work_function, fft_cache) 64 if axis != -1: 65 a = swapaxes(a, axis, -1) --- 66 r = work_function(a, wsave) 67 if axis != -1: 68 r = swapaxes(r, axis, -1) TypeError: array cannot be safely cast to required type This is strange, because I can run fft(array([0,0,0,1,1,1])), or fft([0,0,0,1,1,1]), perfectly fine. This is passing an array and a list, respectively. type(mixfrac) is list and size(mixfrac) is 100; type(mixfracarray) is ndarray, and mixfracarray.shape is (100,). I've also tried taking the FFT of the transpose of mixfracarray, but that doesn't work either. I'm stumped - why can't I run an FFT on either mixfrac or mixfracarray? After you convert to an array what is the array type? I suspect an object in there somewhere. Chuck ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] can't take FFT of ndarray
In [3]: type(mixfrac) Out[3]: type 'list' In [4]: mixfracarray=array(mixfrac) In [5]: type(mixfracarray) Out[5]: type 'numpy.ndarray' (Is that what you were referring to?) On Fri, Mar 6, 2009 at 3:44 PM, Charles R Harris charlesr.har...@gmail.comwrote: On Fri, Mar 6, 2009 at 3:36 PM, charles reid charlesre...@gmail.comwrote: Hi there - I've imported some data from a file, and it's in a list called mixfrac. I'd like to take the Fourier transform of the data, but when I try to take the FFT of the list, I get this error: --- TypeError Traceback (most recent call last) /Users/charles/apriori/read.py in module() 1 2 3 4 5 /Library/Python/2.5/site-packages/numpy-1.3.0.dev5825-py2.5-macosx-10.3-i386.egg/numpy/fft/fftpack.pyc in fft(a, n, axis) 105 106 -- 107 return _raw_fft(a, n, axis, fftpack.cffti, fftpack.cfftf, _fft_cache) 108 109 /Library/Python/2.5/site-packages/numpy-1.3.0.dev5825-py2.5-macosx-10.3-i386.egg/numpy/fft/fftpack.pyc in _raw_fft(a, n, axis, init_function, work_function, fft_cache) 64 if axis != -1: 65 a = swapaxes(a, axis, -1) --- 66 r = work_function(a, wsave) 67 if axis != -1: 68 r = swapaxes(r, axis, -1) TypeError: array cannot be safely cast to required type so I convert to an array and run fft(mixfracarray). mixfracarray = array(mixfrac) fft(mixfracarray) whereupon I recieve the error --- TypeError Traceback (most recent call last) /Users/charles/apriori/read.py in module() 1 2 3 4 5 /Library/Python/2.5/site-packages/numpy-1.3.0.dev5825-py2.5-macosx-10.3-i386.egg/numpy/fft/fftpack.pyc in fft(a, n, axis) 105 106 -- 107 return _raw_fft(a, n, axis, fftpack.cffti, fftpack.cfftf, _fft_cache) 108 109 /Library/Python/2.5/site-packages/numpy-1.3.0.dev5825-py2.5-macosx-10.3-i386.egg/numpy/fft/fftpack.pyc in _raw_fft(a, n, axis, init_function, work_function, fft_cache) 64 if axis != -1: 65 a = swapaxes(a, axis, -1) --- 66 r = work_function(a, wsave) 67 if axis != -1: 68 r = swapaxes(r, axis, -1) TypeError: array cannot be safely cast to required type This is strange, because I can run fft(array([0,0,0,1,1,1])), or fft([0,0,0,1,1,1]), perfectly fine. This is passing an array and a list, respectively. type(mixfrac) is list and size(mixfrac) is 100; type(mixfracarray) is ndarray, and mixfracarray.shape is (100,). I've also tried taking the FFT of the transpose of mixfracarray, but that doesn't work either. I'm stumped - why can't I run an FFT on either mixfrac or mixfracarray? After you convert to an array what is the array type? I suspect an object in there somewhere. Chuck ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] can't take FFT of ndarray
On Fri, Mar 6, 2009 at 3:51 PM, charles reid charlesre...@gmail.com wrote: In [3]: type(mixfrac) Out[3]: type 'list' In [4]: mixfracarray=array(mixfrac) In [5]: type(mixfracarray) Out[5]: type 'numpy.ndarray' Try mixfracarray.dtype ...Chuck snip ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] can't take FFT of ndarray
In [3]: mixfracarray=array(mixfrac) In [4]: mixfracarray.dtype Out[4]: dtype('|S17') On Fri, Mar 6, 2009 at 4:09 PM, Charles R Harris charlesr.har...@gmail.comwrote: On Fri, Mar 6, 2009 at 3:51 PM, charles reid charlesre...@gmail.comwrote: In [3]: type(mixfrac) Out[3]: type 'list' In [4]: mixfracarray=array(mixfrac) In [5]: type(mixfracarray) Out[5]: type 'numpy.ndarray' Try mixfracarray.dtype ...Chuck snip ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] can't take FFT of ndarray
This indicates that the values are strings, so you can't make an FFT from them. Convert your array to float or double array first. Matthieu 2009/3/7 charles reid charlesre...@gmail.com: In [3]: mixfracarray=array(mixfrac) In [4]: mixfracarray.dtype Out[4]: dtype('|S17') On Fri, Mar 6, 2009 at 4:09 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Fri, Mar 6, 2009 at 3:51 PM, charles reid charlesre...@gmail.com wrote: In [3]: type(mixfrac) Out[3]: type 'list' In [4]: mixfracarray=array(mixfrac) In [5]: type(mixfracarray) Out[5]: type 'numpy.ndarray' Try mixfracarray.dtype ...Chuck snip ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion -- Information System Engineer, Ph.D. Website: http://matthieu-brucher.developpez.com/ Blogs: http://matt.eifelle.com and http://blog.developpez.com/?blog=92 LinkedIn: http://www.linkedin.com/in/matthieubrucher ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] can't take FFT of ndarray
On Fri, Mar 6, 2009 at 4:22 PM, charles reid charlesre...@gmail.com wrote: In [3]: mixfracarray=array(mixfrac) In [4]: mixfracarray.dtype Out[4]: dtype('|S17') It's a string array. What does your file look like and how do you import it? Chuck ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] can't take FFT of ndarray
Fixed the problem - I was importing a bunch of numbers from a file, and I wasn't casting them as doubles. Thanks for the help! Charles On Fri, Mar 6, 2009 at 4:26 PM, Charles R Harris charlesr.har...@gmail.comwrote: On Fri, Mar 6, 2009 at 4:22 PM, charles reid charlesre...@gmail.comwrote: In [3]: mixfracarray=array(mixfrac) In [4]: mixfracarray.dtype Out[4]: dtype('|S17') It's a string array. What does your file look like and how do you import it? Chuck ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Assigning complex values to a real array
On Fri, Mar 6, 2009 at 6:18 PM, Stéfan van der Walt ste...@sun.ac.zawrote: Hi all, The following code succeeds, while I thought it should fail: a = np.zeros(6) # real b= np.arange(6)*(2+3j) # complex a[1] = b[1] # shouldn't this break? What is the rationale behind this behaviour? The same as this: In [1]: a = zeros(2) In [2]: a[0] = '1' In [3]: a Out[3]: array([ 1., 0.]) The question is whether such usage is likely in error, calling for an exception, or a useful convenience to avoid a cast. I tend to think that casts should be made explicit in such cases but it's a fine line. What about this? In [5]: a = zeros(2) In [6]: a[0] = 1 In [7]: a Out[7]: array([ 1., 0.]) Should a cast be required? What if the lhs is a float32 and the rhs is a python float? Chuck ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion