Re: [Numpy-discussion] log of negative real numbers -> RuntimeWarning: invalid value encountered in log

2020-05-25 Thread Brian Racey
if it isn't documented elsewhere. On Mon, May 25, 2020 at 11:17 AM Sebastian Berg wrote: > On Mon, 2020-05-25 at 11:10 -0400, Robert Kern wrote: > > On Mon, May 25, 2020 at 10:36 AM Sebastian Berg < > > sebast...@sipsolutions.net> > > wrote: > > > > >

Re: [Numpy-discussion] log of negative real numbers -> RuntimeWarning: invalid value encountered in log

2020-05-25 Thread Brian Racey
o my input values that are generally complex resolved my issue. On Mon, May 25, 2020 at 10:09 AM Brian Racey wrote: > Thanks. That is for performance and memory which of course is valid for > most use cases. Would it really be much different than doing type/size > checking of all the np

Re: [Numpy-discussion] log of negative real numbers -> RuntimeWarning: invalid value encountered in log

2020-05-25 Thread Brian Racey
The input array is iterated over, and log evaluated on each element in >turn > > In either case, you’ve converted a 1-pass iteration to a 2-pass one. > > There are static-typing-based explanations for this behavior too, but I’ll > let someone else present one of those. > > Eric

[Numpy-discussion] log of negative real numbers -> RuntimeWarning: invalid value encountered in log

2020-05-25 Thread Brian Racey
Why does numpy produce a runtime warning (invalid value encountered in log) when taking the log of a negative number? I noticed that if you coerce the argument to complex by adding 0j to the negative number, the expected result is produced (i.e. ln(-1) = pi*i). I was surprised I couldn't find a di