[Numpy-discussion] TypeError when calling numpy.kaiser()
josef.pktd at gmail.com
josef.pktd at gmail.com
Wed Oct 21 11:18:05 EDT 2009
On Sun, Oct 18, 2009 at 3:11 PM, Jeffrey McGee <jeffamcgee at gmail.com> wrote:
> Howdy,
> I'm having trouble getting the kaiser window to work. Anytime I try
> to call numpy.kaiser(), it throws an exception. Here's the output when
> I run the example code from
> http://docs.scipy.org/doc/numpy/reference/generated/numpy.kaiser.html :
>
>
> Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
> [GCC 4.3.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>
>>>> from numpy import kaiser
>>>> kaiser(12, 14)
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
>
> File "/usr/lib/python2.6/dist-packages/numpy/lib/function_base.py",
> line 2630, in kaiser
> return i0(beta * sqrt(1-((n-alpha)/alpha)**2.0))/i0(beta)
> File "/usr/lib/python2.6/dist-packages/numpy/lib/function_base.py",
>
> line 2507, in i0
> y[ind] = _i0_1(x[ind])
> TypeError: array cannot be safely cast to required type
>>>>
>
>
> Is this a bug? Am I doing something wrong? (I'm using the Ubuntu 9.4
>
> packages for python and numpy.)
> Thanks,
> Jeff
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
It works with my numpy 1.3.0, but np.i0 doesn't like integers.
Can you try with a float 14. instead of the integer?
np.kaiser(12, 14.)
You could file a ticket, and we see if the experts consider
this a feature or a bug. (I don't know anything about kaiser
or i0)
Josef
>>> np.kaiser(12,14)
array([ 7.72686684e-06, 3.46009194e-03, 4.65200189e-02,
2.29737120e-01, 5.99885316e-01, 9.45674898e-01,
9.45674898e-01, 5.99885316e-01, 2.29737120e-01,
4.65200189e-02, 3.46009194e-03, 7.72686684e-06])
>>> np.i0(1)
Traceback (most recent call last):
File "<pyshell#46>", line 1, in <module>
np.i0(1)
File "C:\Programs\Python25\Lib\site-packages\numpy\lib\function_base.py",
line 2484, in i0
y[ind] = _i0_1(x[ind])
TypeError: array cannot be safely cast to required type
>>> np.i0(1.)
array(1.2660658777520082)
More information about the NumPy-Discussion
mailing list