Example #1
0
def test_transform_bad_tree():
    with pytest.raises(TypeError):
        _ = list(cirq.transform_op_tree(None))
    with pytest.raises(TypeError):
        _ = list(cirq.transform_op_tree(5))
    with pytest.raises(TypeError):
        _ = list(cirq.flatten_op_tree(cirq.transform_op_tree([
            cirq.GateOperation(cirq.Gate(), [cirq.NamedQubit('q')]), (4,)
        ])))
Example #2
0
def test_transform_bad_tree():
    with pytest.raises(TypeError):
        _ = list(cirq.transform_op_tree(None))
    with pytest.raises(TypeError):
        _ = list(cirq.transform_op_tree(5))
    with pytest.raises(TypeError):
        _ = list(cirq.flatten_op_tree(cirq.transform_op_tree([
            cirq.GateOperation(cirq.Gate(), [cirq.QubitId()]), (4,)
        ])))
Example #3
0
            def __call__(_self, qubits, **kwargs) -> cirq.OP_TREE:
                _op_tree = self.__call__(qubits, **kwargs)
                _resolved_op_tree = cirq.transform_op_tree(
                    _op_tree,
                    op_transformation=(lambda op: cirq.resolve_parameters(
                        op, param_resolver)))

                return _resolved_op_tree
Example #4
0
 def skip_tree_freeze(root):
     return cirq.freeze_op_tree(
         cirq.transform_op_tree(root, iter_transformation=skip_first))
Example #5
0
 def move_tree_left_freeze(root):
     return cirq.freeze_op_tree(cirq.transform_op_tree(root, move_left))
Example #6
0
 def skip_tree_freeze(root):
     return cirq.freeze_op_tree(
         cirq.transform_op_tree(root, iter_transformation=skip_first))
Example #7
0
 def move_tree_left_freeze(root):
     return cirq.freeze_op_tree(
         cirq.transform_op_tree(root, move_left))