MCPcopy
hub / github.com/ray-project/ray / extend

Method extend

rllib/env/utils/infinite_lookback_buffer.py:120–134  ·  view source on GitHub ↗

Appends all items in `items` to the end of this buffer.

(self, items)

Source from the content-addressed store, hash-verified

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`.

Calls 1

appendMethod · 0.95