"""Checks of decode.py: python test_decode.py.""" import numpy as np import decode assert decode.episodes(np.array([0, 1, 1, 0, 1, 0, 0, 1])) == [[1, 4], [7, 7]] # one instant bridged, two not assert decode.named("PB1_2 alone, unlike PB1 and PB2_2.", ["PB1", "PB1_2", "PB2", "PR12"]) == [0, 1] instants = np.array(["t0", "t1", "t2", "t3", "t4", "t5"]) yhat = np.zeros((6, 1), np.uint8) yhat[1:3, 0] = 1 c = decode.score_station([{"start": "t2", "end": "t3"}, {"start": "t5", "end": "t5"}], instants, yhat, 0) assert c[:4] == [2, 1, 1, 1] and c[4] == [1 / 3], c # label t2..t3 and episode t1..t2 share t2 of t1..t3 print("ok")