statsmodels / statsmodels

Statsmodels: statistical modeling and econometrics in Python
http://www.statsmodels.org/devel/
BSD 3-Clause "New" or "Revised" License
10.13k stars 2.88k forks source link

FAQ-D inplace negation #1945

Open josef-pkt opened 10 years ago

josef-pkt commented 10 years ago

Is there a way to negate a boolean, or to change the sign of a float inplace?

np.logical_not(arr, out=arr) np.negative(arr, out=arr)

might be useful for negating loglike and similar during optimization.

(asked on numpy mailing list)

bashtage commented 10 years ago

Alternative in-place negation:

x *= -1.0