[Numpy-discussion] numpy.floor() is supposed to return an int, but returns a float
Webb Sprague
webb.sprague at gmail.com
Sun Apr 9 15:40:02 CDT 2006
I think the docstring implies that numpy.floor() returns an integer
value. One can cast the float value to a usable integer value, but
either the docstring should read something different or the function
should be changed (my preference).
"y = floor(x) elementwise largest integer <= x" is the docstring.
As far as "integral valued float" versus "integer", this distinction
seems a little obscure... I am sure the difference is very important
in some contexts, but I for one think that floor should return a
straight up integer, if just for code style (see example below). Plus
it will be upcast to a float whenever necessary, so floor(4.5) + .75
== 4.75 whether floor() returns an int or a float.
fooMatrix[numpy.floor(age/ageWidth)]
is better (easier to type, read, and debug) than
fooMatrix[numpy.floor(age/ageWidth).astype(int)]
If there is a explanation as to why an integral valued float is a
better return value, I would be interested in a link.
Thx
W
More information about the Numpy-discussion
mailing list