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