[Numpy-discussion] Strange behavior of np.sinc

David Goldsmith d.l.goldsmith at gmail.com
Sun Jun 27 13:46:12 EDT 2010


On Sat, Jun 26, 2010 at 10:00 PM, David Goldsmith
<d.l.goldsmith at gmail.com>wrote:

> On Sat, Jun 26, 2010 at 9:39 PM, Robert Kern <robert.kern at gmail.com>wrote:
>
>> On Sat, Jun 26, 2010 at 23:33, David Goldsmith <d.l.goldsmith at gmail.com>
>> wrote:
>> > Hi!  The docstring for numpy.lib.function_base.sinc indicates that the
>> > parameter has to be an ndarray, and that it will return the limiting
>> value 1
>> > for sinc(0).  Checking to see if it should actually say array_like, I
>> found
>> > the following (Python 2.6):
>> >
>> >>>> np.sinc(np.array((0,0.5)))
>> > array([ 1.        ,  0.63661977])
>> >>>> np.sinc((0,0.5))
>> > array([        NaN,  0.63661977])
>> >>>> np.sinc([0,0.5])
>> > array([        NaN,  0.63661977])
>> >>>> np.version.version
>> > '1.4.1'
>> >
>> > So, it doesn't choke on non-array sequences, and appears to return
>> values
>> > consistent w/ array input, except at 0.  Bug in code (failure at 0 if in
>> a
>> > sequence) and in the doc (ndarray should be array_like)?
>>
>> Bug in both code and docs. There should be an "x = np.asanyarray(x)"
>> before the rest of the code.
>>
>
> Thanks Robert; I'll file a ticket and fix the docstring.
>
> DG
>

All done (patched this morning and Pauli's checked it in already - nice when
they're easy).

DG

-- 
Mathematician: noun, someone who disavows certainty when their uncertainty
set is non-empty, even if that set has measure zero.

Hope: noun, that delusive spirit which escaped Pandora's jar and, with her
lies, prevents mankind from committing a general suicide.  (As interpreted
by Robert Graves)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100627/be74bcf1/attachment.html>


More information about the NumPy-Discussion mailing list