diff tests/test_grid.py @ 0:5dba84370182

initial commit; half-working prototype
author Jeff Hammel <k0scist@gmail.com>
date Sat, 24 Jun 2017 12:03:39 -0700
parents
children 1b94f3bf97e5
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_grid.py	Sat Jun 24 12:03:39 2017 -0700
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+
+"""
+test that we can grid a solution
+"""
+
+import unittest
+from globalneighbors.grid import LatLonGrid
+
+class TestGrid(unittest.TestCase):
+    """test gridding functionality"""
+
+    def test_dimensions(self):
+
+        # make a 2 degree grid
+        grid = LatLonGrid(90, 180)
+        assert grid.n == (90, 180)
+        assert grid.d == (2., 2.)
+
+    def test_insertion(self):
+
+        coord = (-23., 122.)
+        grid = LatLonGrid(3, 4)
+        grid.add(1234, *coord)
+        i, j = grid.index(*coord)
+        assert i == 1
+        assert j == 3
+        assert grid[(i,j)] == [1234]
+
+if __name__ == '__main__':
+    unittest.main()