<div dir="ltr">> On 2017-09-25 10:59, Renato Fabbri wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> > """<br>
> > In [3]: n.floor(n.linspace(0,5,7), dtype=<a href="http://n.int" rel="noreferrer" target="_blank">n.int</a> <<a href="http://n.int" rel="noreferrer" target="_blank">http://n.int</a>>)<br>
> > ------------------------------<wbr>------------------------------<br>
> ---------------<br>
> > TypeError                                 Traceback (most recent call<br>
> last)<br>
> > <ipython-input-3-1471f5d738e8> in <module>()<br>
> > ----> 1 n.floor(n.linspace(0,5,7), dtype=<a href="http://n.int" rel="noreferrer" target="_blank">n.int</a> <<a href="http://n.int" rel="noreferrer" target="_blank">http://n.int</a>>)<br>
> ><br>
> > TypeError: No loop matching the specified signature and casting<br>
> > was found for ufunc floor<br>
> ><br>
> > In [4]: n.__version__<br>
> > Out[4]: '1.11.0'<br>
> > """<br>
> ><br>
> > Is this the expected behavior?<br>
><br>
> Yes. There is no floor function for integers.<br>
><br>
> The dtype argument specified not only the return type, but the type the<br>
> calculation is done in as well. floor() only exists, and only makes<br>
> sense, for floats. (You can use floor(a, dtype='f4') and so on to insist<br>
> on floats of a different width)<br></blockquote><div><br></div><div>+1 for specifying a dtype in np.floor and np.ceil.</div><div><br></div><div>Now it is pretty odd that np.floor and np.ceil results in an integer, except for that it doesn't. it returns a float with all zeros as the decimals. It would be very useful to be able to specify the dtype at 'int'. I frequently use floor or ceil to determine the indices of an array, but now need to convert to integers in addition to floor and ceil. </div></div><br></div></div>