[Numpy-discussion] Asymmetry in Chebyshev.deriv v. Chebyshev.integ

David Goldsmith d.l.goldsmith@gmail....
Fri Apr 2 13:04:31 CDT 2010


On Fri, Apr 2, 2010 at 10:42 AM, Charles R Harris <charlesr.harris@gmail.com
> wrote:

>
> On Thu, Apr 1, 2010 at 7:42 PM, David Goldsmith <d.l.goldsmith@gmail.com>wrote:
>
>> >>> np.version.version
>> '1.4.0'
>> >>> c = np.polynomial.chebyshev.Chebyshev(1)
>> >>> c.deriv(1.0)
>> Chebyshev([ 0.], [-1.,  1.])
>> >>> c.integ(1.0)
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in <module>
>>   File "<string>", line 441, in integ
>>   File "C:\Python26\lib\site-packages\numpy\polynomial\chebyshev.py", line
>> 739,
>> in chebint
>>     k = list(k) + [0]*(m - len(k))
>> TypeError: can't multiply sequence by non-int of type 'float'
>> >>> c.integ(1)
>> Chebyshev([ 0.,  1.], [-1.,  1.])
>
>
> I don't think it should accept a float when an integer is needed. That
> said, I should either raise a more informative error or folks should
> convince me that floats are a reasonable input for the number of
> integrations.
>
> Chuck
>

My only concern is API consistency: if you want to restrict the integ input
to int dtypes, that's fine, but then why allow non-int dtypes in deriv
(which, BTW, accepts much more than just int_like floats - it works with one
element lists containing an int_like float, and similar numpy arrays, even
zero-order Polynomial objects (I didn't check tuples, but given all that,
I'd be surprised if it didn't))?  Superficially, this is a pretty big API
discrepancy; ultimately of course it doesn't matter, but I'd like to know
where we want to land so I can make sure the docstrings correctly document
desired behavior.

DG
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100402/1cc91465/attachment.html 


More information about the NumPy-Discussion mailing list