[Numpy-discussion] Piecewise functions.

Andrea Riciputi ariciputi at pito.com
Tue Sep 27 02:10:32 EDT 2005


On Sep 26, 2005, at 7:43 PM, Travis Oliphant wrote:

> This is not a trivial problem in current versions of Numeric.
>
> What are you using, Numeric, numarray?
>
> In new scipy core (which replaces Numeric) and, I think, in  
> numarray, you could say
>
> gta = x>a
> lea = x<=a
> y = x.copy()
> y[gta] = f2(x[gta])
> y[lea] = f1(x[lea])
>
> I've also just written a piecewise function for the new scipy core  
> so you could write
>
> y = piecewise(x, x<=a, [f1,f2])
>
> -Travis Oliphant

Yes I'm using Numeric, and in the short to middle term I'll stay with  
it. Anyway I'm aware of the effort you are spending in putting  
together a Numeric replacement, and I'll look forward for a stable  
release of it. In the meanwhile I'll use the tricks already suggested  
here.

Thanks again for your effort,
  Andrea.





More information about the NumPy-Discussion mailing list