[Numpy-discussion] Piecewise functions.
ariciputi at pito.com
Fri Sep 23 00:03:07 CDT 2005
On Sep 23, 2005, at 5:23 AM, Greg Ewing wrote:
> I wish people would stop suggesting the 'a and b or c' trick,
> because it DOESN'T WORK except in special circumstances (i.e.
> when you can be sure that b is never false).
> What you want is:
> def f(x):
> if x <= a:
> return f1(x)
> return f2(x)
It doesn't work either. As I've already explained x is an array
containing values both above and below a!
What I really need is a way to prevent f1 and f2 from acting on those
values of the 'x' array for which the functions are not defined.
Any other hints?
More information about the Numpy-discussion