# [Numpy-discussion] How to do : x[i,j] = y[k, j] with k = i+sj

Nicolas ROUX nicolas.roux@st....
Mon Oct 27 10:38:30 CDT 2008

```Hi,

Me again ;-)
I have now a new question to ask (I hope not too silly).

How to do :

for j in range(yHeight):
for i in range(xWidth):
x[j,i] = y[k,i] with k = numpy.mod(i+sj,yHeight)

With efficient numpy code, without the double "for" ?

Thanks,

Cheers,
Nicolas.

-----Original Message-----
From: numpy-discussion-bounces@scipy.org
[mailto:numpy-discussion-bounces@scipy.org] On Behalf Of Uwe Schmitt
Sent: Monday, October 27, 2008 12:46 PM
To: Discussion of Numerical Python
Subject: Re: [Numpy-discussion] [mailinglist] How to do: y[y<T] = y+T

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

or explicitely (slower/more memory):

y[y<T] = y[y<T] + T

Greetings, Uwe
> To benefit from the Numpy speed.
> But this doesn't work, any idea ?
>
> Thanks,
> Cheers,
> Nicolas.
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
>

--
Dr. rer. nat. Uwe Schmitt
F&E Mathematik

mineway GmbH
Science Park 2
D-66123 Saarbrücken

Telefon: +49 (0)681 8390 5334
Telefax: +49 (0)681 830 4376

uschmitt@mineway.de
www.mineway.de

Geschäftsführung: Dr.-Ing. Mathias Bauer
Amtsgericht Saarbrücken HRB 12339

_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

```

More information about the Numpy-discussion mailing list