[Numpy-discussion] [mailinglist] How to do: y[y<T] = y+T

Gabriel Gellner ggellner at uoguelph.ca
Mon Oct 27 08:06:34 EDT 2008


On Mon, Oct 27, 2008 at 12:45:44PM +0100, Uwe Schmitt wrote:
> Nicolas ROUX schrieb:
> > Hello,
> >
> > I hope this is not a silly question ;-)
> > I have a Numpy array, and I want to process it with :
> >   "if the value is lower than Threshold, then increase by Threshold"
> >
> >
> > I would like to translate it as:
> >  y[y<Treshold] = y + Treshold
> >   
> Hi,
> 
> your solution does not work, becaus the arrays on both
> side do not have the same size in generall.
> 
> You can do it in place:
> 
>     y[y<T] += T
> 
Nice, I didn't know this :-) Thanks.

Gabriel



More information about the NumPy-Discussion mailing list