comparison 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
comparison
equal deleted inserted replaced
6:316e1d54ffd4 7:254195d0bac2
33 33
34 def neighbors(self, i, j): 34 def neighbors(self, i, j):
35 """ 35 """
36 return neighbors of points i, j 36 return neighbors of points i, j
37 """ 37 """
38 imat = [] 38 imat = [i]
39 jmat = [] 39 jmat = [j]
40 40
41 # latitude 41 # latitude
42 if i: 42 if i:
43 imat.append(i-1) 43 imat.append(i-1)
44 raise NotImplementedError('TODO') 44 if i < self.n[0]-1:
45 imat.append(i+1)
46
47 # longitude: wraps around
48 if j:
49 jmat.append(j-1)
50 else:
51 jmat.append(self.n[-1] - 1)
52 if j == self.n[-1] - 1:
53 jmat.append(0)
54 else:
55 jmat.append(j+1)
56
57 return [(_i, _j) for _i in imat for _j in jmat
58 if (_i,_j) != (i,j)]