Discussion:
[Numpy-discussion] Using numpy.rint() with scalars
Yuri Sukhov
2016-11-03 15:17:26 UTC
Permalink
Hi all,

According to the documentation for numpy.rint() (https://docs.scipy.org/doc/
numpy/reference/generated/numpy.rint.html), it's a ufunc that accepts an
array-like object as an input.

But it also works with scalar inputs. Could anyone clarify if such use case
is considered to be common and acceptable? It it just the documentation
that does not cover one of the possible scenarios, or is it a side effect
and such use case should be avoided?

I want to use rint() with scalars as I have not found an alternative with
the same behavior in cPython, but if it's not how it should be used, I
don't want to rewrite the app when that behavior will change.

Thanks!

Yuri.
Charles R Harris
2016-11-03 15:31:18 UTC
Permalink
Post by Yuri Sukhov
Hi all,
According to the documentation for numpy.rint() (
https://docs.scipy.org/doc/numpy/reference/generated/numpy.rint.html),
it's a ufunc that accepts an array-like object as an input.
But it also works with scalar inputs. Could anyone clarify if such use
case is considered to be common and acceptable? It it just the
documentation that does not cover one of the possible scenarios, or is it a
side effect and such use case should be avoided?
I want to use rint() with scalars as I have not found an alternative with
the same behavior in cPython, but if it's not how it should be used, I
don't want to rewrite the app when that behavior will change.
Scalars are array_like, they can be converted to arrays.

Chuck

Loading...