Returns overlapping ranges from intervals overlapping this interval. Args: intervals: Sequence of candidate intervals to test for overlap. Returns: 2D numpy array indicating the start and end of the overlapping ranges.
(
self,
intervals: Sequence[Self],
)
| 518 | return output |
| 519 | |
| 520 | def overlap_ranges( |
| 521 | self, |
| 522 | intervals: Sequence[Self], |
| 523 | ) -> np.ndarray: |
| 524 | """Returns overlapping ranges from intervals overlapping this interval. |
| 525 | |
| 526 | Args: |
| 527 | intervals: Sequence of candidate intervals to test for overlap. |
| 528 | |
| 529 | Returns: |
| 530 | 2D numpy array indicating the start and end of the overlapping ranges. |
| 531 | """ |
| 532 | output = [] |
| 533 | for interval in intervals: |
| 534 | if not self.overlaps(interval): |
| 535 | continue |
| 536 | relative_start = max(interval.start - self.start, 0) |
| 537 | relative_end = min(interval.end - self.start, self.width) |
| 538 | output.append([relative_start, relative_end]) |
| 539 | |
| 540 | return ( |
| 541 | np.asarray(output, dtype=np.int32) |
| 542 | if output |
| 543 | else np.empty((0, 2), dtype=np.int32) |
| 544 | ) |
| 545 | |
| 546 | def binary_mask( |
| 547 | self, intervals: Sequence[Self], bin_size: int = 1 |