On Sun, Feb 8, 2009 at 2:17 PM, dk <Dan.K...@dal.ca> wrote:
>
> First, an apology: I am not sure I'm doing this entirely correctly.
>
> Commands typed
> ==============
>
> from scipy.signal.filter_design import *
> butter(2,0.5)
>
> Result
> =====
>
> An error (traceback given below).
This problem is caused by the fact that numpy and scipy don't play
totally nicely with Sage's types. There are a couple ways around
this. First, you could use the 'r' suffix to tell Sage not to use its
data types for these numbers.
sage: from scipy.signal.filter_design import *
sage: butter(2r,0.5r)
(array([ 0.29289322, 0.58578644, 0.29289322]),
array([ 1.00000000e+00, -1.95106077e-16, 1.71572875e-01]))
sage: type(2)
<type 'sage.rings.integer.Integer'>
sage: type(2r)
<type 'int'>
sage: type(0.5)
<type 'sage.rings.real_mpfr.RealLiteral'>
sage: type(0.5r)
<type 'float'>
Or you could turn the preparser off:
sage: preparser(False)
sage: butter(2,0.5)
(array([ 0.29289322, 0.58578644, 0.29289322]),
array([ 1.00000000e+00, -1.95106077e-16, 1.71572875e-01]))
I think it'd be a good project to see what would have to be done to
make numpy and scipy work with the Sage data types.
--Mike
Actually, "sage -ipython" would probably be a bit more useful.
--Mike