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

Method set

penzai/core/selectors.py:343–353  ·  view source on GitHub ↗

Replaces the selected subtree(s) with a fixed replacement. Args: replacement: The pytree to replace with. Returns: A modified version of the original tree, with this replacement in place of any selected subtrees.

(self, replacement: Any)

Source from the content-addressed store, hash-verified

341 return new_selection.deselect()
342
343 def set(self, replacement: Any) -> Any:
344 """Replaces the selected subtree(s) with a fixed replacement.
345
346 Args:
347 replacement: The pytree to replace with.
348
349 Returns:
350 A modified version of the original tree, with this replacement in place
351 of any selected subtrees.
352 """
353 return self.apply(lambda _: replacement)
354
355 def get_by_path(self) -> collections.OrderedDict[KeyPath, SelectedSubtree]:
356 """Retrieves the selected subtree(s) based on their path(s).

Callers 8

partitionMethod · 0.95
__call__Method · 0.45
test_selection_setMethod · 0.45
__call__Method · 0.45
__call__Method · 0.45
__call__Method · 0.45

Calls 1

applyMethod · 0.95

Tested by 5

test_selection_setMethod · 0.36
__call__Method · 0.36
__call__Method · 0.36
__call__Method · 0.36