Get the frame number from `other` for arithmetic operations.
(self, other: "TimecodeLike")
| 519 | return as_float |
| 520 | |
| 521 | def _get_other_as_frames(self, other: "TimecodeLike") -> int: |
| 522 | """Get the frame number from `other` for arithmetic operations.""" |
| 523 | if isinstance(other, int): |
| 524 | return other |
| 525 | if isinstance(other, float): |
| 526 | return self._seconds_to_frames(other) |
| 527 | if isinstance(other, str): |
| 528 | return self._seconds_to_frames(self._timecode_to_seconds(other)) |
| 529 | if isinstance(other, Timecode): |
| 530 | return self._seconds_to_frames(other.seconds) |
| 531 | if isinstance(other, FrameTimecode): |
| 532 | # If comparing two FrameTimecodes, they must have the same framerate for frame-based |
| 533 | # operations. |
| 534 | if self._rate and other._rate and not self.equal_frame_rate(other._rate): |
| 535 | raise ValueError( |
| 536 | "FrameTimecode instances require equal frame rate for frame-based arithmetic." |
| 537 | ) |
| 538 | if isinstance(other._time, _FrameNumber): |
| 539 | return other._time.value |
| 540 | # If other has no frame_num, it must have a timecode. Convert to frames. |
| 541 | return self._seconds_to_frames(other.seconds) |
| 542 | raise TypeError("Cannot obtain frame number for this timecode.") |
| 543 | |
| 544 | def __eq__(self, other: "TimecodeLike") -> bool: |
| 545 | if other is None: |
no test coverage detected