def pytestcase_load_event_plus_delta_t_npy(tmpdir): """Tests loading a define number of events and consecutively a time window""" filename, bboxes = create_temporary_npy_file( tmpdir, "load_event_plus_delta_t", "99999 0 BB_CREATE 7 96 102 22 21 0.3\n" "99999 2 BB_CREATE 7 127 87 53 53 0.3\n" "99999 3 BB_CREATE 7 141 81 119 78 0.7\n" "100000 4 BB_CREATE 7 97 102 22 21 0.3\n" "100000 5 BB_CREATE 6 8 69 51 53 0.6\n" "199999 6 BB_CREATE 7 127 87 53 53 0.4\n" "199999 7 BB_CREATE 7 141 81 119 78 0.7\n") record = EventNpyReader(filename) assert record.current_event_index() == 0 assert record.event_count() == 7 assert record.current_time == 0 events = record.load_n_events(3) assert record.done is False # current time should be the timestamp of the event that will be loaded next assert record.current_time == 99999 + 1 events = record.load_delta_t(15000) assert record.current_event_index() == 0 + 3 + 2 assert all([ np.allclose(events[name], bboxes[name][3:5]) for name in events.dtype.names ]) assert record.done is False assert record.current_time == 99999 + 1 + 15000 assert record.done is False
def pytestcase_load_delta_t_too_much_npy(tmpdir): """Tests loading events in a time window larger than total file duration""" filename, bboxes = create_temporary_npy_file( tmpdir, "delta_t_too_much", "99999 0 BB_CREATE 7 96 102 22 21 0.3\n" "99999 2 BB_CREATE 7 127 87 53 53 0.3\n" "99999 3 BB_CREATE 7 141 81 119 78 0.7\n" "100000 4 BB_CREATE 7 97 102 22 21 0.3\n" "100000 5 BB_CREATE 6 8 69 51 53 0.6\n" "199999 6 BB_CREATE 7 127 87 53 53 0.4\n" "199999 7 BB_CREATE 7 141 81 119 78 0.7\n") record = EventNpyReader(filename) assert record.current_event_index() == 0 assert record.event_count() == 7 assert record.current_time == 0 events = record.load_delta_t(100000) assert record.done is False events = record.load_delta_t(10 * 100000) assert record.done assert all([ np.allclose(events[name], bboxes[name][3:]) for name in events.dtype.names ]) # current_time should be last event timestamp + 1 assert record.current_time == 199999 + 1
def pytestcase_load_delta_t_npy(tmpdir): """Tests loading events inside a time window""" filename, bboxes = create_temporary_npy_file( tmpdir, "delta_t", "99999 0 BB_CREATE 7 96 102 22 21 0.3\n" "99999 2 BB_CREATE 7 127 87 53 53 0.3\n" "99999 3 BB_CREATE 7 141 81 119 78 0.7\n" "100000 4 BB_CREATE 7 97 102 22 21 0.3\n" "100000 5 BB_CREATE 6 8 69 51 53 0.6\n" "199999 6 BB_CREATE 7 127 87 53 53 0.4\n" "199999 7 BB_CREATE 7 141 81 119 78 0.7\n") record = EventNpyReader(filename) assert record.current_event_index() == 0 assert record.event_count() == 7 assert record.current_time == 0 events = record.load_delta_t(100000) assert record.done is False assert all([ np.allclose(events[name], bboxes[name][:3]) for name in events.dtype.names ]) assert record.current_event_index() == 0 + 3 # current time should be 0 + 100000 assert record.current_time == 100000