forked from kkoziara/stops2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_utils.py
More file actions
23 lines (17 loc) · 842 Bytes
/
test_utils.py
File metadata and controls
23 lines (17 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
__author__ = 'Kamil Koziara'
import unittest
import numpy
from utils import HexGrid
class TestStopUtils(unittest.TestCase):
def test_hex_grid(self):
xctrs = [(0.0, 0.0), (2.0, 0.0), (1.0, 1.7320508075688774), (3.0, 1.7320508075688774)]
xarr = numpy.array([[ 0. , 2. , 2. , 3.46410162],
[ 2. , 0. , 2. , 2. ],
[ 2. , 2. , 0. , 2. ],
[ 3.46410162, 2. , 2. , 0. ]])
grid = HexGrid(2, 2, 2)
self.assertEqual([2, 2], grid.shape)
self.assertEqual(xctrs, grid.xy)
self.assertTrue(numpy.allclose(xarr, grid.adj_mat), "Distance arrays are not equal.")
if __name__ == '__main__':
unittest.main()