[Numpy-discussion] How to do: y[y<T] = y+T
Gabriel Gellner
ggellner@uoguelph...
Mon Oct 27 06:47:48 CDT 2008
On Mon, Oct 27, 2008 at 12:41:06PM +0100, Nicolas ROUX wrote:
> 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
>
You are close, you just need to have the right hand side also use vector
indexing (since otherwise you are trying to add something of length y to a
subset of y):
y[y < Threshold] = y[y < Threshold] + Threshold
Gabriel
More information about the Numpy-discussion
mailing list