-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_events.py
24 lines (19 loc) · 893 Bytes
/
test_events.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
import os
import cPickle as pickle
from nose.tools import assert_equal, assert_true
from events import detect_events, detect_events_given_path
CURDIR = os.path.dirname(os.path.abspath(__file__))
def test_detect_events():
result_path = os.path.join(CURDIR, 'test/data/cand_trees.pkl')
cand_trees = pickle.load(open(result_path))
trees = detect_events(cand_trees, K=5)
assert_equal(5, len(trees))
for t1, t2 in zip(trees, trees[1:]):
assert_true(len(t1.nodes()) >= len(t2.nodes()))
def test_detect_events_given_path():
result_path = os.path.join(CURDIR, 'test/data/cand_trees.pkl')
cand_trees = pickle.load(open(result_path))
expected_trees = detect_events(cand_trees, K=5)
actual_trees = detect_events_given_path(result_path, K=5)
for at, et in zip(actual_trees, expected_trees):
assert_equal(sorted(et.edges()), sorted(at.edges()))