![]() |
A classical control condition based on a sympy expression.
Inherits From: Condition
cirq.SympyCondition(
expr: sympy.Basic
)
This condition resolves to True iff the sympy expression resolves to a
truthy value (i.e. bool(x) == True
) when the measurement keys are
substituted in as the free variables.
sympy.IndexedBase
can be used for bitwise conditions. For example, the
following will create a condition that is controlled by the XOR of the
first two bits (big-endian) of measurement 'a'.
>>> a = sympy.IndexedBase('a')
>>> cond = cirq.SympyCondition(sympy.Xor(a[0], a[1]))
Attributes | |
---|---|
keys
|
Gets the control keys. |
qasm
|
Returns the qasm of this condition. |
expr
|
Dataclass field |
Methods
replace_key
replace_key(
current: 'cirq.MeasurementKey', replacement: 'cirq.MeasurementKey'
)
Replaces the control keys.
resolve
resolve(
classical_data: 'cirq.ClassicalDataStoreReader'
) -> bool
Resolves the condition based on the measurements.
__eq__
__eq__(
other
)
Return self==value.