Appends all items in `items` to the end of this buffer.
(self, items)
| 118 | self.data.append(item) |
| 119 | |
| 120 | def extend(self, items) -> None: |
| 121 | """Appends all items in `items` to the end of this buffer.""" |
| 122 | if self.finalized: |
| 123 | # TODO (sven): When extending with a list of structs, we should |
| 124 | # probably rather do: `tree.map_structure(..., self.data, |
| 125 | # tree.map_structure(lambda *s: np.array(*s), *items)`)?? |
| 126 | self.data = tree.map_structure( |
| 127 | lambda d, i: np.concatenate([d, i], axis=0), |
| 128 | self.data, |
| 129 | # Note, we could have dictionaries here. |
| 130 | np.array(items) if isinstance(items, list) else items, |
| 131 | ) |
| 132 | else: |
| 133 | for item in items: |
| 134 | self.append(item) |
| 135 | |
| 136 | def concat(self, other: "InfiniteLookbackBuffer") -> None: |
| 137 | """Concatenates the data of `other` (w/o its lookback) to `self`. |