Ejemplo 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)))
Ejemplo 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)
Ejemplo 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))
             )
Ejemplo n.º 4
0
 def _has_channel_(self):
     return not self._is_parameterized_() and protocols.has_channel(
         self.sub_gate)
Ejemplo n.º 5
0
 def _has_channel_(self) -> bool:
     return protocols.has_channel(self.sub_operation)
Ejemplo n.º 6
0
 def keep(potential_op: ops.Operation) -> bool:
     return (protocols.has_channel(potential_op)
             or isinstance(potential_op.gate, ops.MeasurementGate))
Ejemplo n.º 7
0
 def measure_or_mixture(op):
     return not protocols.has_unitary(op) and (
         protocols.is_measurement(op) or protocols.has_channel(op))
Ejemplo n.º 8
0
 def _has_channel_(self) -> bool:
     return protocols.has_channel(self.gate)
Ejemplo 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))
Ejemplo 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)