Skip to content

Commit

Permalink
account for float code_nums
Browse files Browse the repository at this point in the history
In some files, code_num for random region #10 was "10." for some reason.
I will now do str -> float -> int and hope there aren't code nums like "3.2".
  • Loading branch information
kalenkovich committed Sep 19, 2022
1 parent 0d1ba03 commit 5ece97f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion blabpy/vihi/intervals/intervals.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ def add_annotation_intervals_to_eaf(eaf, intervals):
assert not two_lists_of_intervals_overlap(existing_code_intervals_list, new_code_intervals_list)

# Figure out which code_num we should start with (it is last_code_num + 1)
existing_code_nums = [int(code_num) for code_num in eaf.get_values('code_num')]
# (in a few cases, code_num was '10.', hence the int(float())
existing_code_nums = [int(float(code_num)) for code_num in eaf.get_values('code_num')]
last_code_num = 0 if len(existing_code_nums) == 0 else max(existing_code_nums)
n_intervals_to_add = intervals.shape[0]
new_code_nums = list(range(last_code_num + 1, last_code_num + n_intervals_to_add + 1))
Expand Down

0 comments on commit 5ece97f

Please sign in to comment.