There is a positive
function in numpy
(version 1.13+), which seemingly does nothing:
In [1]: import numpy as np
In [2]: A = np.array([0, 1, -1, 1j, -1j, 1+1j, 1-1j, -1+1j, -1-1j, np.inf, -np.inf])
In [3]: A == np.positive(A)
Out[3]:
array([ True, True, True, True, True, True, True, True, True,
True, True])
The documentation says: Returned array or scalar: `y = +x`
What are the use cases of this function?
x.copy()
, but only defined for types that support arithmetic.. I guess that's it, that look pretty useless – Acuate"np.positive" extension:.py language:Python
and there are a lot of hits - many false hits. Sorting it byreently indexed
brought some to the top: those look like there being used in unittests. – Whimwhamnp.positive
for the purpose of copying, if he has an explicitnp.copy
? (Apart from the fact thatnp.positive
is aufunc
which means it is written in C.) For me it would look like a bad code style. – Snowboundnp.negative
to some arrays, andnp.positive
to others, both with the same set of added parameters (order
,casting
etc). You probably wouldn't use it plain and in isolation, but as part of larger code it might be useful. Why are we allowed to write+12.34
when12.34
is just as good? Why does Python define apass
that does nothing? – Brittle