MCPcopy
hub / github.com/Qiskit/qiskit / _validate_expr

Function _validate_expr

qiskit/circuit/quantumcircuit.py:7876–7889  ·  view source on GitHub ↗
(circuit_scope: CircuitScopeInterface, node: expr.Expr)

Source from the content-addressed store, hash-verified

7874
7875
7876def _validate_expr(circuit_scope: CircuitScopeInterface, node: expr.Expr) -> expr.Expr:
7877 # This takes the `circuit_scope` object as an argument rather than being a circuit method and
7878 # inferring it because we may want to call this several times, and we almost invariably already
7879 # need the interface implementation for something else anyway.
7880 # If we're not in a capturing scope (i.e. we're in the root scope), then the
7881 # `use_{var,stretch}` calls are no-ops.
7882 for ident in set(expr.iter_identifiers(node)):
7883 if isinstance(ident, expr.Stretch):
7884 circuit_scope.use_stretch(ident)
7885 elif ident.standalone:
7886 circuit_scope.use_var(ident)
7887 else:
7888 circuit_scope.resolve_classical_resource(ident.var)
7889 return node
7890
7891
7892def _copy_metadata(original, cpy):

Callers 6

appendMethod · 0.85
add_varMethod · 0.85
while_loopMethod · 0.85
if_testMethod · 0.85
if_elseMethod · 0.85
switchMethod · 0.85

Calls 3

use_stretchMethod · 0.45
use_varMethod · 0.45

Tested by

no test coverage detected