Esempio n. 1
0
 def keep(potential_op: ops.Operation) -> bool:
     return (protocols.has_channel(potential_op)
             or (ops.op_gate_of_type(potential_op, ops.MeasurementGate)
                 is not None)
             or isinstance(potential_op,
                           (ops.SamplesDisplay, ops.WaveFunctionDisplay,
                            ops.DensityMatrixDisplay)))
Esempio n. 2
0
def is_measurement(val: Any) -> bool:
    """Returns whether or not the given value is a measurement.

    A measurement must implement the `measurement_key` protocol and have a
    channel, as represented by the `has_channel` protocol returning true.
    """
    return measurement_key(val, None) is not None and has_channel(val)
Esempio n. 3
0
 def keep(potential_op: ops.Operation) -> bool:
     return (protocols.has_channel(potential_op)
             or ops.MeasurementGate.is_measurement(potential_op)
             or isinstance(potential_op,
                           (ops.SamplesDisplay,
                               ops.WaveFunctionDisplay,
                               ops.DensityMatrixDisplay))
             )
Esempio n. 4
0
 def _has_channel_(self):
     return not self._is_parameterized_() and protocols.has_channel(
         self.sub_gate)
Esempio n. 5
0
 def _has_channel_(self) -> bool:
     return protocols.has_channel(self.sub_operation)
Esempio n. 6
0
 def keep(potential_op: ops.Operation) -> bool:
     return (protocols.has_channel(potential_op)
             or isinstance(potential_op.gate, ops.MeasurementGate))
Esempio n. 7
0
 def measure_or_mixture(op):
     return not protocols.has_unitary(op) and (
         protocols.is_measurement(op) or protocols.has_channel(op))
Esempio n. 8
0
 def _has_channel_(self) -> bool:
     return protocols.has_channel(self.gate)
Esempio n. 9
0
 def keep(potential_op: ops.Operation) -> bool:
     return (protocols.has_channel(potential_op)
             or (ops.op_gate_of_type(potential_op, ops.MeasurementGate)
                 is not None))
Esempio n. 10
0
 def keep(potential_op: ops.Operation) -> bool:
     return protocols.has_channel(
         potential_op, allow_decompose=False) or isinstance(
             potential_op.gate, ops.MeasurementGate)