<br><br>On Friday, September 16, 2011, Charles R Harris <<a href="mailto:charlesr.harris@gmail.com">charlesr.harris@gmail.com</a>> wrote:<br>><br>><br>> On Fri, Sep 16, 2011 at 9:11 AM, Benjamin Root <<a href="mailto:ben.root@ou.edu">ben.root@ou.edu</a>> wrote:<br>
>><br>>> Certain numerical types in Python that support accurate fractional calculations such as timedelta and Decimal do not allow for multiplication or division by a floating point number, but do allow for use with an integer.  This can cause difficulties with some functions such as np.gradient() which has a division by 2.0 as part of the algorithm.<br>
>><br>>> My question is: with Py3k's division always resulting in a floating point result regardless of the denominator's type, would it be possible to change some of these common denominators over to integers in order to better facilitate support for these special types?<br>
>><br>>> Obviously, I don't think we could expect full support of these types, but maybe a mechanism could be developed to better handle these?<br>>><br>><br>> Timedelta seems to work in master:<br>
><br>> In [1]: timedelta64(5)<br>> Out[1]: numpy.timedelta64(5)<br>><br>> In [2]: timedelta64(5)/2.0<br>> Out[2]: numpy.timedelta64(2)<br>><br>> In [3]: timedelta64(5)/2<br>> Out[3]: numpy.timedelta64(2)<br>
>  <br>> I think making the change to 2 is a reasonable thing to do, but you should put a<br>><br>> from __future__ import division<br>><br>> at the beginning of the module containing gradient and make sure everything still works.<br>
><br>> Chuck<br>><br>><br><br>I am referring to a numpy array of python timedeltas, not numpy's.<br><br>Ben Root