Add (concatencate) two Annotation objects in-place. Both annotations must have the same orig_time
(self, other)
| 478 | return out |
| 479 | |
| 480 | def __iadd__(self, other): |
| 481 | """Add (concatencate) two Annotation objects in-place. |
| 482 | |
| 483 | Both annotations must have the same orig_time |
| 484 | """ |
| 485 | if len(self) == 0: |
| 486 | self._orig_time = other.orig_time |
| 487 | if self.orig_time != other.orig_time: |
| 488 | raise ValueError( |
| 489 | "orig_time should be the same to add/concatenate 2 annotations (got " |
| 490 | f"{self.orig_time} != {other.orig_time})" |
| 491 | ) |
| 492 | extras = other.extras |
| 493 | if hasattr(other, "hed_string"): |
| 494 | extras = _hed_extras_from_hed_annotations(other) |
| 495 | return self.append( |
| 496 | other.onset, |
| 497 | other.duration, |
| 498 | other.description, |
| 499 | other.ch_names, |
| 500 | extras=extras, |
| 501 | ) |
| 502 | |
| 503 | def __iter__(self): |
| 504 | """Iterate over the annotations.""" |
no test coverage detected