diff globalneighbors/grid.py @ 1:1b94f3bf97e5

* limit distance function * start gridding * improve unicode handling
author Jeff Hammel <k0scist@gmail.com>
date Sat, 24 Jun 2017 14:02:14 -0700
parents 5dba84370182
children 7e27e874655b
line wrap: on
line diff
--- a/globalneighbors/grid.py	Sat Jun 24 12:03:39 2017 -0700
+++ b/globalneighbors/grid.py	Sat Jun 24 14:02:14 2017 -0700
@@ -13,18 +13,18 @@
         self.create_grid()
 
     def create_grid(self):
-        self.grid = [[] for _ in xrange(self.n[-1])
-                     for _ in xrange(self.n[0])]
+        self.grid = []
+        for _ in xrange(self.n[0]):
+            self.grid.append([set() for _ in xrange(self.n[-1])])
 
     def add(self, geoid, lat, lon):
         latlon = (lat, lon)
-        self[self.index(lat, lon)].append(geoid)
+        self[self.index(lat, lon)].add(geoid)
 
     def __getitem__(self, index):
         """
         index -- 2-tuple or list of i and j indices
         """
-        import pdb; pdb.set_trace()
         return self.grid[index[0]][index[1]]
 
     def index(self, lat, lon):
@@ -35,3 +35,5 @@
         """
         return neighbors of points i, j
         """
+        if i:
+            raise NotImplementedError('TODO')