Example #1
0
def test_get_program_id_4():
    circuit = cirq.Circuit(cirq.H(cirq.LineQubit(0)))
    circuit.program_id = "abcd1234/" * 20
    assert len(circuit.program_id) > 64
    prog_id = _get_program_id(circuit)
    assert isinstance(prog_id, str)
    # too many parts, it defaults back to uuid
    val = uuid.UUID(prog_id, version=4)
Example #2
0
def test_get_program_id_2():
    circuit = cirq.Circuit(cirq.H(cirq.LineQubit(0)))
    circuit.program_id = "my_fancy_var_1/my_fancy_var_2/x-3"
    prog_id = _get_program_id(circuit)
    assert isinstance(prog_id, str)
    with pytest.raises(ValueError):
        val = uuid.UUID(prog_id, version=4)
    assert prog_id.startswith("my_fancy_var_1_my_fancy_var_2_x-3")
Example #3
0
def test_get_program_id_3():
    circuit = cirq.Circuit(cirq.H(cirq.LineQubit(0)))
    circuit.program_id = ("my_fancy_var_1/my_fancy_var_2/my_fancy_var_3/"
                          "my_fancy_var_4/my_fancy_var_5/my_fancy_var_6")
    assert len(circuit.program_id) > 64
    prog_id = _get_program_id(circuit)
    assert isinstance(prog_id, str)
    with pytest.raises(ValueError):
        val = uuid.UUID(prog_id, version=4)
    assert prog_id.startswith(
        "my_far_1_my_far_2_my_far_3_my_far_4_my_far_5_my_far_6_")
Example #4
0
def test_get_program_id():
    circuit = cirq.Circuit(cirq.H(cirq.LineQubit(0)))
    prog_id = _get_program_id(circuit)
    assert isinstance(prog_id, str)
    assert uuid.UUID(prog_id, version=4)