MCPcopy
hub / github.com/google-deepmind/penzai / set_sequence

Method set_sequence

penzai/core/selectors.py:419–433  ·  view source on GitHub ↗

Replaces the selected subtree(s) in order. Args: replacements: An iterable of PyTrees to insert at the selected locations, in order. Returns: A modified version of the original tree, with replacements taken from the iterable.

(self, replacements: Iterable[Any])

Source from the content-addressed store, hash-verified

417 return tuple(self.selected_by_path.values())
418
419 def set_sequence(self, replacements: Iterable[Any]) -> Any:
420 """Replaces the selected subtree(s) in order.
421
422 Args:
423 replacements: An iterable of PyTrees to insert at the selected locations,
424 in order.
425
426 Returns:
427 A modified version of the original tree, with replacements taken from the
428 iterable.
429 """
430 replacer = {}
431 for keypath, replacement in zip(self.selected_by_path.keys(), replacements):
432 replacer[keypath] = replacement
433 return self.set_by_path(replacer)
434
435 def flatten_selected_selections(
436 self: "Selection[Selection[SelectedSubtree]]",

Callers 3

bodyMethod · 0.80

Calls 1

set_by_pathMethod · 0.95

Tested by 1