diff globalneighbors/grid.py @ 7:254195d0bac2

partial implementation of autocomplete using jqueryui; easyautocomplete.com may be more what we want
author Jeff Hammel <k0scist@gmail.com>
date Sun, 25 Jun 2017 09:13:48 -0700
parents 7e27e874655b
children 638fad06e556
line wrap: on
line diff
--- a/globalneighbors/grid.py	Sat Jun 24 15:47:59 2017 -0700
+++ b/globalneighbors/grid.py	Sun Jun 25 09:13:48 2017 -0700
@@ -35,10 +35,24 @@
         """
         return neighbors of points i, j
         """
-        imat = []
-        jmat = []
+        imat = [i]
+        jmat = [j]
 
         # latitude
         if i:
             imat.append(i-1)
-            raise NotImplementedError('TODO')
+        if i < self.n[0]-1:
+            imat.append(i+1)
+
+        # longitude: wraps around
+        if j:
+            jmat.append(j-1)
+        else:
+            jmat.append(self.n[-1] - 1)
+        if j == self.n[-1] - 1:
+            jmat.append(0)
+        else:
+            jmat.append(j+1)
+
+        return [(_i, _j) for _i in imat for _j in jmat
+                if (_i,_j) != (i,j)]