2010-08-13 7 views
0

J'utilise la dernière version de numpy/scipy.
Le script suivant ne fonctionne pas:est fftshift cassé dans scipy?

import numpy as np 
import matplotlib.pyplot as plt 
from scipy.fftpack import fft, fftshift, fftfreq 
hn= np.ones(10) 
hF = fft(hn,1024) 
shifted = fftshift(hF) 

Il donne le message d'erreur suivant:

Traceback (most recent call last): 
    File "D:\deleteme\New3.py", line 6, in <module> 
    shifted = fftshift(hF) 
    File "C:\Python26\lib\site-packages\numpy\fft\helper.py", line 40, in fftshift 
    y = take(y,mylist,k) 
    File "C:\Python26\lib\site-packages\numpy\core\fromnumeric.py", line 103, in take 
    return take(indices, axis, out, mode) 
TypeError: array cannot be safely cast to required type 

EDIT: j'ai trouvé le problème. Mon interpréteur python a été implicitement appelé (via mes paramètres d'éditeur) avec l'option -Qnew. Cela brise apparemment le code scipy. Merci à tous ceux qui ont répondu!

+0

Fonctionne bien pour moi. Êtes-vous sûr que le code est copié correctement? – katrielalex

+0

a également bien fonctionné pour moi. J'utilise les dernières versions de Numpy (1.5.0b1) et Scipy (0.8.0rc3). –

Répondre

0

fonctionne très bien avec ma configuration, si c'est un bug dans la version actuelle essayer d'installer une ancienne copie et remplir un rapport.

>>> import numpy as np 
>>> import matplotlib.pyplot as plt 
>>> from scipy.fftpack import fft, fftshift, fftfreq 
>>> hn= np.ones(10) 
>>> hF = fft(hn,1024) 
>>> shifted = fftshift(hF) 
>>> shifted 
array([ 0.00000000+0.j  , 0.00084688+0.03066325j, 
     0.00338468+0.06122841j, ..., 0.00760489-0.09159769j, 
     0.00338468-0.06122841j, 0.00084688-0.03066325j]) 


>>> import sys 
>>> sys.version 
'2.6.4 (r264:75706, Jan 22 2010, 16:41:54) [MSC v.1500 32 bit (Intel)]' 
>>> import numpy 
>>> numpy.version.version 
'1.3.0' 
>>> import scipy 
>>> scipy.version.version 
'0.7.1' 
>>> import matplotlib 
>>> matplotlib.__version__ 
'0.99.1' 
>>>