def test_aspen_qubit_qid_conversions(): """test AspenQubit conversion to and from other `cirq.Qid` implementations""" qubit10 = AspenQubit(1, 0) assert qubit10.to_named_qubit() == cirq.NamedQubit('10') assert AspenQubit.from_named_qubit(cirq.NamedQubit('10')) == AspenQubit( 1, 0) with pytest.raises(ValueError): _ = AspenQubit.from_named_qubit(cirq.NamedQubit('s')) with pytest.raises(ValueError): _ = AspenQubit.from_named_qubit(cirq.NamedQubit('19')) with pytest.raises(ValueError): _ = qubit10.to_grid_qubit() assert AspenQubit(0, 2).to_grid_qubit() == cirq.GridQubit(0, 0) assert AspenQubit(0, 1).to_grid_qubit() == cirq.GridQubit(1, 0) assert AspenQubit(1, 5).to_grid_qubit() == cirq.GridQubit(0, 1) assert AspenQubit(1, 6).to_grid_qubit() == cirq.GridQubit(1, 1) assert AspenQubit.from_grid_qubit(cirq.GridQubit(1, 1)) == AspenQubit(1, 6) with pytest.raises(ValueError): _ = AspenQubit.from_grid_qubit(cirq.GridQubit(3, 4))
qcs_aspen8_isa: InstructionSetArchitecture): """test RigettiQCSAspenDevice topological nodes and edges""" device = RigettiQCSAspenDevice(isa=qcs_aspen8_isa) assert len(device.qubit_topology.nodes) == 32 assert len(device.qubit_topology.edges) == 38 @pytest.mark.parametrize( 'qubit', [ cirq.GridQubit(0, 0), cirq.GridQubit(1, 1), cirq.LineQubit(30), cirq.NamedQubit('33'), AspenQubit(3, 6), OctagonalQubit(6), ], ) def test_rigetti_qcs_aspen_device_valid_qubit( qubit: cirq.Qid, qcs_aspen8_isa: InstructionSetArchitecture): """test RigettiQCSAspenDevice throws no error on valid qubits or operations on those qubits""" device = RigettiQCSAspenDevice(isa=qcs_aspen8_isa) device.validate_qubit(qubit) device.validate_operation(cirq.I(qubit)) @pytest.mark.parametrize( 'qubit', [ cirq.GridQubit(2, 2),