MCPcopy Create free account
hub / github.com/DedalusProject/dedalus / replace

Method replace

dedalus/core/future.py:117–129  ·  view source on GitHub ↗

Replace specified operand/operator.

(self, old, new)

Source from the content-addressed store, hash-verified

115 return any(arg.has(*vars) for arg in self.args if isinstance(arg, Operand))
116
117 def replace(self, old, new):
118 """Replace specified operand/operator."""
119 # Check for entire expression match
120 if self == old:
121 return new
122 # Check base and call with replaced arguments
123 elif isinstance(old, type) and isinstance(self,old):
124 args = [arg.replace(old, new) if isinstance(arg, Operand) else arg for arg in self.args]
125 return new(*args)
126 # Call with replaced arguments
127 else:
128 args = [arg.replace(old, new) if isinstance(arg, Operand) else arg for arg in self.args]
129 return self.new_operands(*args)
130
131 # def simplify(self, *vars):
132 # """Simplify expression, except subtrees containing specified variables."""

Callers 12

setup.pyFile · 0.45
__str__Method · 0.45
__str__Method · 0.45
__str__Method · 0.45
__str__Method · 0.45
__str__Method · 0.45
split_callFunction · 0.45
build_EVPMethod · 0.45
__init__Method · 0.45

Calls 1

new_operandsMethod · 0.45

Tested by

no test coverage detected