Find common intervals between two sets of intervals.
(intervals1, intervals2)
| 35 | raise ValueError(f"Unexpected data format in {evaluation_file}") |
| 36 | |
| 37 | def find_common_intervals(intervals1, intervals2): |
| 38 | """Find common intervals between two sets of intervals.""" |
| 39 | intervals1 = torch.tensor(intervals1, dtype=torch.float32) |
| 40 | intervals2 = torch.tensor(intervals2, dtype=torch.float32) |
| 41 | start_max = torch.max(intervals1[:, 0].unsqueeze(1), intervals2[:, 0]) |
| 42 | end_min = torch.min(intervals1[:, 1].unsqueeze(1), intervals2[:, 1]) |
| 43 | overlap_mask = start_max < end_min |
| 44 | common_intervals = torch.stack((start_max, end_min), dim=2)[overlap_mask] |
| 45 | return common_intervals |
| 46 | |
| 47 | def calculate_angle(vector1, vector2): |
| 48 | """Calculate angle between two vectors.""" |
no outgoing calls
no test coverage detected