Пример #1
0
def test_transform_bad_tree():
    with pytest.raises(TypeError):
        _ = list(op_tree.transform_op_tree(None))
    with pytest.raises(TypeError):
        _ = list(op_tree.transform_op_tree(5))
    with pytest.raises(TypeError):
        _ = list(op_tree.flatten_op_tree(op_tree.transform_op_tree([
            Operation(Gate(), [QubitId()]), (4,)
        ])))
Пример #2
0
 def on(self, *args: raw_types.QubitId,
        **kwargs: raw_types.QubitId) -> gate_operation.GateOperation:
     if not kwargs:
         return super().on(*args)
     if not args and set(kwargs.keys()) == {'control', 'target'}:
         return super().on(kwargs['control'], kwargs['target'])
     raise ValueError(
         "Expected two positional argument or else 'target' AND 'control' "
         "keyword arguments. But got args={!r}, kwargs={!r}.".format(
             args, kwargs))