Hi Rafael,

On Sun, Jul 26, 2009 at 6:29 AM, Rafael Costa<rfc...@gmail.com> wrote:
>
> Why Sage not execute the python code?
>
> from scipy import *
> from pylab import *
>
> sample_rate=1000.00
> t=r_[0:0.6:1/sample_rate]
> N=len(t)
> s=sin(2*pi*50*t)+sin(2*pi*70*t+pi/4)
> S=fft(s)
> f=sample_rate*r_[0:(N/2)]/N
> n=len(f)
> plot(f,abs(S[0:n])/N)

Well, I get this far:

----------------------------------------------------------------------
| Sage Version 4.1, Release Date: 2009-07-09                         |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: from scipy import *
sage: from pylab import *
sage: sample_rate = 1000.0
sage: t = r_[0:0.6:1/sample_rate]
sage: N = len(t)
sage: s = [sin(2*pi*50*elem) + sin(2*pi*70*elem + (pi/4)) for elem in t]
sage: S = fft(s)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/mvngu/.sage/temp/sage.math.washington.edu/6349/_home_mvngu__sage_init_sage_0.py
in <module>()

/usr/local/sage/local/lib/python2.6/site-packages/numpy/fft/fftpack.pyc
in fft(a, n, axis)
    157     """
    158
--> 159     return _raw_fft(a, n, axis, fftpack.cffti, fftpack.cfftf,
_fft_cache)
    160
    161

/usr/local/sage/local/lib/python2.6/site-packages/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


The problem is that Sage and NumPy do not yet talk to each other very
well. The relevant tickets to accomplish this are:

#6497
http://trac.sagemath.org/sage_trac/ticket/6497

#5081
http://trac.sagemath.org/sage_trac/ticket/5081

#6506
http://trac.sagemath.org/sage_trac/ticket/6506

-- 
Regards
Minh Van Nguyen

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to