[Numpy-discussion] Identification of neighbouring sites for a periodic numpy array
Bill Baxter
wbaxter@gmail....
Thu Apr 5 16:06:17 CDT 2007
On 4/4/07, Andy Cheesman <Andy.cheesman@bristol.ac.uk> wrote:
> Hi people,
>
> I was wondering if people could give me a pointer or two upon the
> efficient identification of neighbouring sites for a given point upon a
> numpy array which has periodic conditions.
> Suggestions upon the web I've seen seem to use lots of loops which does
> not seem to be the most economical method.
Neighbors of x[i] in array x with length N are
x[[i-1,i,(i+1)%N]]
The -1 is ok without a guard because x[-1] is the last element of a
list in python.
If that's not what you were after then you might need to be more
specific about the context you're talking about.
> Sorry if this is muppet-ish post!
I do not know what you mean. You think you sound like Kermit the Frog
or Fozzie Bear? You do not. And I think we all know that it really
isn't easy being green.
:-)
--bb
More information about the Numpy-discussion
mailing list