Re: [Numpy-discussion] Unexpected RuntimeWarning

2012-11-23 Thread Charles R Harris
On Fri, Nov 23, 2012 at 4:38 AM, Bob Dowling wrote: > I have a simple function defined in the following snippet: > > --- start --- > import numpy > > def chebyshev(x, m): > '''Calculates Chebyshev functions of the first kind using the > trigonometric identities.''' > > theta = numpy.w

Re: [Numpy-discussion] Unexpected RuntimeWarning

2012-11-23 Thread Bob Dowling
> You may want to use this: > http://docs.scipy.org/doc/numpy/reference/generated/numpy.piecewise.html Thank you. That's just what I needed. Works a treat: --- start --- import numpy def chebyshev(x, m): '''Calculates Chebyshev functions of the first kind using the trigonometric identi

Re: [Numpy-discussion] Unexpected RuntimeWarning

2012-11-23 Thread Pauli Virtanen
Bob Dowling cam.ac.uk> writes: [clip] > I'm guessing that numpy.where() is evaluating the complete arccos and > arccosh arrays and therefore getting invalid arguments. > > Now, I can turn off the warnings with numpy.seterr(invalid='ignore') but > that's not what I would regard as good practice.

[Numpy-discussion] Unexpected RuntimeWarning

2012-11-23 Thread Bob Dowling
I have a simple function defined in the following snippet: --- start --- import numpy def chebyshev(x, m): '''Calculates Chebyshev functions of the first kind using the trigonometric identities.''' theta = numpy.where( numpy.abs(x)<=1.0, numpy.arccos(x), n