-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoslo_unittests.py
32 lines (25 loc) · 955 Bytes
/
oslo_unittests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import unittest
from oslo import *
class TestOslo(unittest.TestCase):
def test1(self):
model = OsloModel(16)
for _ in range(400): # run the model for a long time to reach the steady state
model.run()
result = []
for i in range(3_000_000): # take average over t=5000
model.run()
result.append(model.heights[0])
# noinspection PyTypeChecker
self.assertAlmostEqual(np.mean(result), 26.5, places=1)
def test2(self):
model = OsloModel(32)
for _ in range(1500): # run the model for a long time to reach the steady state
model.run()
result = []
for i in range(3_000_000): # take average over t=5000
model.run()
result.append(model.heights[0])
# noinspection PyTypeChecker
self.assertAlmostEqual(np.mean(result), 53.9, places=1)
if __name__ == '__main__':
unittest.main()