comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:5dba84370182
1 #!/usr/bin/env python
2
3 """
4 test that we can grid a solution
5 """
6
7 import unittest
8 from globalneighbors.grid import LatLonGrid
9
10 class TestGrid(unittest.TestCase):
11 """test gridding functionality"""
12
13 def test_dimensions(self):
14
15 # make a 2 degree grid
16 grid = LatLonGrid(90, 180)
17 assert grid.n == (90, 180)
18 assert grid.d == (2., 2.)
19
20 def test_insertion(self):
21
22 coord = (-23., 122.)
23 grid = LatLonGrid(3, 4)
24 grid.add(1234, *coord)
25 i, j = grid.index(*coord)
26 assert i == 1
27 assert j == 3
28 assert grid[(i,j)] == [1234]
29
30 if __name__ == '__main__':
31 unittest.main()