Skip to content

Commit

Permalink
Implement tests for new adjust_times=True behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
justinsalamon committed Oct 31, 2016
1 parent 9f3c4d0 commit 3dec6c9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/jams_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,20 @@ def __test_error(ann, start_time, end_time, strict=False):
duration=2.0)
assert ann_trim.data.equals(expected_ann.data)

# Make sure annotation and observation times are adjusted when
# adjust_times = True
ann_trim = ann.trim(8, 10, adjust_times=True)
expected_data = dict(time=[0.0],
duration=[1.0],
value=['two'],
confidence=[0.9])

expected_ann = jams.Annotation(namespace, data=expected_data, time=0.0,
duration=2.0)
assert ann_trim.time == 0
assert ann_trim.duration == 2
assert ann_trim.data.equals(expected_ann.data)


def test_jams_trim():

Expand Down Expand Up @@ -899,3 +913,9 @@ def __test_error(jam, start_time, end_time, strict=False):
del orig_file_metadata['duration']
del trim_file_metadata['duration']
assert trim_file_metadata == orig_file_metadata

# Trim with adjust times
jam_trim_adjust = jam.trim(8, 10, adjust_times=True)
ann_trim = ann_copy.trim(8, 10)
for ann in jam_trim.annotations:
assert ann.data.equals(ann_trim.data)

0 comments on commit 3dec6c9

Please sign in to comment.