def test_update_calibrations(self): """Test that we can properly update an instance of Calibrations.""" freq01 = FakeArmonk().defaults().qubit_freq_est[0] backend = MockIQBackend( experiment_helper=SpectroscopyHelper(freq_offset=5e6, line_width=2e6), iq_cluster_centers=[((-1.0, -1.0), (1.0, 1.0))], iq_cluster_width=[0.2], ) backend._configuration.basis_gates = ["x"] backend._configuration.timing_constraints = {"granularity": 16} backend.defaults().qubit_freq_est = [freq01, freq01] library = FixedFrequencyTransmon(basis_gates=["x", "sx"]) cals = Calibrations.from_backend(FakeArmonk(), libraries=[library]) prev_freq = cals.get_parameter_value(cals.__drive_freq_parameter__, (0,)) self.assertEqual(prev_freq, freq01) frequencies = np.linspace(freq01 - 10.0e6, freq01 + 10.0e6, 21) expdata = RoughFrequencyCal(0, cals, frequencies).run(backend) self.assertExperimentDone(expdata) # Check the updated frequency which should be shifted by 5MHz. post_freq = cals.get_parameter_value(cals.__drive_freq_parameter__, (0,)) self.assertTrue(abs(post_freq - freq01 - 5e6) < 1e6)
def test_spectroscopy12_end2end_classified(self): """End to end test of the spectroscopy experiment with an x pulse.""" backend = MockIQBackend( experiment_helper=SpectroscopyHelper(line_width=2e6), iq_cluster_centers=[((-1.0, -1.0), (1.0, 1.0))], iq_cluster_width=[0.2], ) backend._configuration.basis_gates = ["x"] backend._configuration.timing_constraints = {"granularity": 16} qubit = 0 freq01 = backend.defaults().qubit_freq_est[qubit] frequencies = np.linspace(freq01 - 10.0e6, freq01 + 10.0e6, 21) # Note that the backend is not sophisticated enough to simulate an e-f # transition so we run the test with g-e. spec = EFSpectroscopy(qubit, frequencies) spec.backend = backend spec.set_run_options(meas_level=MeasLevel.CLASSIFIED) expdata = spec.run(backend) self.assertExperimentDone(expdata) result = expdata.analysis_results(1) self.assertRoundTripSerializable(result.value, check_func=self.ufloat_equiv) self.assertTrue(freq01 - 2e6 < result.value.n < freq01 + 2e6) self.assertEqual(result.quality, "good") # Test the circuits circ = spec.circuits()[0] self.assertEqual(circ.data[0][0].name, "x") self.assertEqual(circ.data[1][0].name, "Spec")
def test_end_to_end(self, freq_shift): """Test the experiment from end to end.""" qubit = 1 backend = MockIQBackend( experiment_helper=ResonatorSpectroscopyHelper( gate_name="measure", freq_offset=freq_shift), iq_cluster_centers=[((0.0, 0.0), (-1.0, 0.0))], iq_cluster_width=[0.2], ) backend._configuration.timing_constraints = {"granularity": 16} res_freq = backend.defaults().meas_freq_est[qubit] frequencies = np.linspace(res_freq - 20e6, res_freq + 20e6, 51) spec = ResonatorSpectroscopy(qubit, backend=backend, frequencies=frequencies) expdata = spec.run(backend) self.assertExperimentDone(expdata) result = expdata.analysis_results(1) self.assertRoundTripSerializable(result.value, check_func=self.ufloat_equiv) self.assertAlmostEqual(result.value.n, res_freq + freq_shift, delta=0.1e6) self.assertEqual(str(result.device_components[0]), f"R{qubit}")
def test_kerneled_expdata_serialization(self): """Test experiment data and analysis data JSON serialization""" exp_helper = SpectroscopyHelper(line_width=2e6) backend = MockIQBackend( experiment_helper=exp_helper, iq_cluster_centers=[((-1.0, -1.0), (1.0, 1.0))], iq_cluster_width=[0.2], ) backend._configuration.basis_gates = ["x"] backend._configuration.timing_constraints = {"granularity": 16} qubit = 1 freq01 = backend.defaults().qubit_freq_est[qubit] frequencies = np.linspace(freq01 - 10.0e6, freq01 + 10.0e6, 21) exp = QubitSpectroscopy(qubit, frequencies) exp.set_run_options(meas_level=MeasLevel.KERNELED, shots=1024) expdata = exp.run(backend).block_for_results() self.assertExperimentDone(expdata) # Checking serialization of the experiment data self.assertRoundTripSerializable(expdata, self.experiment_data_equiv) # Checking serialization of the analysis self.assertRoundTripSerializable(expdata.analysis_results(1), self.analysis_result_equiv)
def test_kerneled_expdata_serialization(self, freq_shift): """Test experiment data and analysis data JSON serialization""" qubit = 1 backend = MockIQBackend( experiment_helper=ResonatorSpectroscopyHelper( gate_name="measure", freq_offset=freq_shift), iq_cluster_centers=[((0.0, 0.0), (-1.0, 0.0))], iq_cluster_width=[0.2], ) backend._configuration.timing_constraints = {"granularity": 16} res_freq = backend.defaults().meas_freq_est[qubit] frequencies = np.linspace(res_freq - 20e6, res_freq + 20e6, 51) exp = ResonatorSpectroscopy(qubit, backend=backend, frequencies=frequencies) expdata = exp.run(backend).block_for_results() self.assertExperimentDone(expdata) # since under _experiment in kwargs there is an argument of the backend which isn't serializable. expdata._experiment = None # Checking serialization of the experiment data self.assertRoundTripSerializable(expdata, self.experiment_data_equiv) # Checking serialization of the analysis self.assertRoundTripSerializable(expdata.analysis_results(1), self.analysis_result_equiv)
def setUp(self): """Setup the tests""" super().setUp() library = FixedFrequencyTransmon() self.backend = MockIQBackend(FineAmpHelper(-np.pi * 0.07, np.pi, "xp")) self.backend.configuration().basis_gates.append("sx") self.backend.configuration().basis_gates.append("x") self.cals = Calibrations.from_backend(self.backend, libraries=[library])
def test_default_circuits(self): """Test the default circuit.""" backend = MockIQBackend( DragHelper(gate_name="Drag(xp)", frequency=0.005)) drag = RoughDrag(0, self.x_plus) drag.set_experiment_options(reps=[2, 4, 8]) drag.backend = MockIQBackend(DragHelper(gate_name="Drag(xp)")) circuits = drag.circuits() for idx, expected in enumerate([4, 8, 16]): ops = transpile(circuits[idx * 51], backend).count_ops() self.assertEqual(ops["Drag(xp)"], expected)
def test_spectroscopy_end2end_kerneled(self): """End to end test of the spectroscopy experiment on IQ data.""" exp_helper = SpectroscopyHelper(line_width=2e6) backend = MockIQBackend( experiment_helper=exp_helper, iq_cluster_centers=[((-1.0, -1.0), (1.0, 1.0))], iq_cluster_width=[0.2], ) backend._configuration.basis_gates = ["x"] backend._configuration.timing_constraints = {"granularity": 16} qubit = 0 freq01 = backend.defaults().qubit_freq_est[qubit] frequencies = np.linspace(freq01 - 10.0e6, freq01 + 10.0e6, 21) spec = QubitSpectroscopy(qubit, frequencies) expdata = spec.run(backend) self.assertExperimentDone(expdata) result = expdata.analysis_results(1) self.assertRoundTripSerializable(result.value, check_func=self.ufloat_equiv) self.assertTrue(freq01 - 2e6 < result.value.n < freq01 + 2e6) self.assertEqual(result.quality, "good") exp_helper.freq_offset = 5.0e6 backend._iq_cluster_centers = [((1.0, 1.0), (-1.0, -1.0))] spec = QubitSpectroscopy(qubit, frequencies) expdata = spec.run(backend) self.assertExperimentDone(expdata) result = expdata.analysis_results(1) self.assertRoundTripSerializable(result.value, check_func=self.ufloat_equiv) self.assertTrue(freq01 + 3e6 < result.value.n < freq01 + 8e6) self.assertEqual(result.quality, "good") spec.set_run_options(meas_return="avg") expdata = spec.run(backend) self.assertExperimentDone(expdata) result = expdata.analysis_results(1) self.assertRoundTripSerializable(result.value, check_func=self.ufloat_equiv) self.assertTrue(freq01 + 3e6 < result.value.n < freq01 + 8e6) self.assertEqual(result.quality, "good")
def test_run_sx_cal(self): """Test that we can transpile in the calibrations before and after update. If this test passes then we were successful in running a calibration experiment, updating a pulse parameter, having this parameter propagated to the schedules for use the next time the experiment is run. """ # Initial pulse amplitude init_amp = 0.25 amp_cal = FineSXAmplitudeCal(0, self.cals, "sx") circs = transpile(amp_cal.circuits(), self.backend, inst_map=self.cals.default_inst_map) with pulse.build(name="sx") as expected_sx: pulse.play(pulse.Drag(160, 0.25, 40, 0), pulse.DriveChannel(0)) self.assertEqual(circs[5].calibrations["sx"][((0,), ())], expected_sx) # run the calibration experiment. This should update the amp parameter of x which we test. exp_data = amp_cal.run(MockIQBackend(FineAmpHelper(-np.pi * 0.07, np.pi / 2, "sx"))) self.assertExperimentDone(exp_data) d_theta = exp_data.analysis_results(1).value.n new_amp = init_amp * (np.pi / 2) / (np.pi / 2 + d_theta) circs = transpile(amp_cal.circuits(), self.backend, inst_map=self.cals.default_inst_map) sx_cal = circs[5].calibrations["sx"][((0,), ())] # Requires allclose due to numerical precision. self.assertTrue(np.allclose(sx_cal.blocks[0].pulse.amp, new_amp)) self.assertFalse(np.allclose(sx_cal.blocks[0].pulse.amp, init_amp))
def test_update_calibrations(self): """Test that the calibration version of the experiment updates the cals.""" tol = 1e4 # 10 kHz resolution freq_name = self.cals.__drive_freq_parameter__ # Check qubit frequency before running the cal f01 = self.cals.get_parameter_value(freq_name, 0) self.assertTrue( len(self.cals.parameters_table(parameters=[freq_name])["data"]), 1) self.assertEqual(f01, FakeArmonk().defaults().qubit_freq_est[0]) freq_shift = 4e6 osc_shift = 2e6 # oscillation with 6 MHz backend = MockIQBackend( RamseyXYHelper(freq_shift=freq_shift + osc_shift)) expdata = FrequencyCal(0, self.cals, backend, osc_freq=osc_shift).run() self.assertExperimentDone(expdata) # Check that qubit frequency after running the cal is shifted by freq_shift, i.e. 4 MHz. f01 = self.cals.get_parameter_value(freq_name, 0) self.assertTrue( len(self.cals.parameters_table(parameters=[freq_name])["data"]), 2) self.assertTrue( abs(f01 - (freq_shift + FakeArmonk().defaults().qubit_freq_est[0])) < tol)
def setUp(self): """Setup the test.""" super().setUp() library = FixedFrequencyTransmon() self.backend = MockIQBackend(FineDragHelper()) self.cals = Calibrations.from_backend(self.backend, libraries=[library])
def test_data_generation_2qubits(self): """ Test readout angle experiment using a simulator. """ num_qubits = 2 num_shot = 10000 backend = MockIQBackend( MockIQReadoutAngleParallelHelper(), iq_cluster_centers=[((-5.0, 4.0), (-5.0, -4.0)), ((3.0, 1.0), (5.0, -3.0))], iq_cluster_width=[1.0, 2.0], ) circ0 = QuantumCircuit(num_qubits, num_qubits) circ0.x(1) circ0.measure(0, 0) circ0.measure(1, 1) circ0.metadata = {"qubits": [0, 1], "xval": [0, 1]} # Here meas_return is 'avg' so it will average on the results for each qubit. job = backend.run([circ0], shots=num_shot, meas_level=MeasLevel.KERNELED, meas_return="avg") res = job.result() self.assertEqual(len(res.results[0].data.memory), num_qubits) # Circuit to create Bell state backend.experiment_helper = MockIQBellStateHelper() circ1 = QuantumCircuit(num_qubits, num_qubits) circ1.h(0) circ1.cx(0, 1) circ1.measure(0, 0) circ1.measure(1, 1) # Now meas_return will be 'single' so it is expected that the number of results will be as # the number of shots. job = backend.run([circ1], shots=num_shot, meas_level=MeasLevel.KERNELED, meas_return="single") res = job.result() self.assertEqual(len(res.results[0].data.memory), num_shot) for data in res.results[0].data.memory: self.assertEqual(len(data), num_qubits)
def test_end_to_end(self): """A simple test to check if the experiment will run and fit data.""" drag = FineDrag(0, Gate("Drag", num_qubits=1, params=[])) drag.set_experiment_options(schedule=self.schedule) drag.set_transpile_options(basis_gates=["rz", "Drag", "sx"]) exp_data = drag.run(MockIQBackend(FineDragHelper())) self.assertExperimentDone(exp_data) self.assertEqual(exp_data.analysis_results(0).quality, "good")
def setUp(self): """Setup the tests""" super().setUp() library = FixedFrequencyTransmon() self.backend = MockIQBackend(DragHelper(gate_name="Drag(x)")) self.cals = Calibrations.from_backend(self.backend, libraries=[library]) self.test_tol = 0.05
def test_end_to_end(self, freq_shift): """Test the experiment end to end.""" exp_helper = FineFreqHelper(sx_duration=self.sx_duration, freq_shift=freq_shift) backend = MockIQBackend(exp_helper) exp_helper.dt = backend.configuration().dt freq_exp = FineFrequency(0, 160, backend) freq_exp.set_transpile_options(inst_map=self.inst_map) expdata = freq_exp.run(shots=100) self.assertExperimentDone(expdata) result = expdata.analysis_results(1) d_theta = result.value.n dt = backend.configuration().dt d_freq = d_theta / (2 * np.pi * self.sx_duration * dt) tol = 0.01e6 self.assertAlmostEqual(d_freq, freq_shift, delta=tol) self.assertEqual(result.quality, "good")
def test_calibration_version(self): """Test the calibration version of the experiment.""" exp_helper = FineFreqHelper(sx_duration=self.sx_duration, freq_shift=0.1e6) backend = MockIQBackend(exp_helper) exp_helper.dt = backend.configuration().dt fine_freq = FineFrequencyCal(0, self.cals, backend) armonk_freq = FakeArmonk().defaults().qubit_freq_est[0] freq_before = self.cals.get_parameter_value(self.cals.__drive_freq_parameter__, 0) self.assertAlmostEqual(freq_before, armonk_freq) expdata = fine_freq.run() self.assertExperimentDone(expdata) freq_after = self.cals.get_parameter_value(self.cals.__drive_freq_parameter__, 0) # Test equality up to 10kHz on a 100 kHz shift self.assertAlmostEqual(freq_after, armonk_freq + exp_helper.freq_shift, delta=1e4)
def test_spectroscopy_end2end_classified(self): """End to end test of the spectroscopy experiment.""" exp_helper = SpectroscopyHelper(line_width=2e6) backend = MockIQBackend( experiment_helper=exp_helper, iq_cluster_centers=[((-1.0, -1.0), (1.0, 1.0))], iq_cluster_width=[0.2], ) backend._configuration.basis_gates = ["x"] backend._configuration.timing_constraints = {"granularity": 16} qubit = 1 freq01 = backend.defaults().qubit_freq_est[qubit] frequencies = np.linspace(freq01 - 10.0e6, freq01 + 10.0e6, 21) spec = QubitSpectroscopy(qubit, frequencies) spec.set_run_options(meas_level=MeasLevel.CLASSIFIED) expdata = spec.run(backend) self.assertExperimentDone(expdata) result = expdata.analysis_results(1) self.assertRoundTripSerializable(result.value, check_func=self.ufloat_equiv) self.assertTrue(4.999e9 < result.value.n < 5.001e9) self.assertEqual(result.quality, "good") self.assertEqual(str(result.device_components[0]), f"Q{qubit}") # Test if we find still find the peak when it is shifted by 5 MHz. exp_helper.freq_offset = 5.0e6 spec = QubitSpectroscopy(qubit, frequencies) spec.set_run_options(meas_level=MeasLevel.CLASSIFIED) expdata = spec.run(backend) self.assertExperimentDone(expdata) result = expdata.analysis_results(1) self.assertRoundTripSerializable(result.value, check_func=self.ufloat_equiv) self.assertTrue(5.0049e9 < result.value.n < 5.0051e9) self.assertEqual(result.quality, "good")
def test_default_schedule(self): """Test the default schedule.""" rabi = Rabi(2, self.sched) rabi.set_experiment_options(amplitudes=[0.5]) rabi.backend = MockIQBackend(RabiHelper()) circs = rabi.circuits() with pulse.build() as expected: pulse.play(pulse.Gaussian(160, 0.5, 40), pulse.DriveChannel(2)) self.assertEqual(circs[0].calibrations["Rabi"][((2, ), (0.5, ))], expected) self.assertEqual(len(circs), 1)
def test_readout_angle_end2end(self): """ Test readout angle experiment using a simulator. """ backend = MockIQBackend(MockIQReadoutAngleHelper(), iq_cluster_centers=[((-3.0, 3.0), (5.0, 5.0))]) exp = ReadoutAngle(0) expdata = exp.run(backend, shots=100000) self.assertExperimentDone(expdata) res = expdata.analysis_results(0) self.assertAlmostEqual(res.value % (2 * np.pi), np.pi / 2, places=2) backend = MockIQBackend(MockIQReadoutAngleHelper(), iq_cluster_centers=[((0, -3.0), (5.0, 5.0))]) exp = ReadoutAngle(0) expdata = exp.run(backend, shots=100000) self.assertExperimentDone(expdata) res = expdata.analysis_results(0) self.assertAlmostEqual(res.value % (2 * np.pi), 15 * np.pi / 8, places=2)
def test_wrong_processor(self): """Test that we can override the data processing by giving a faulty data processor.""" backend = MockIQBackend(RabiHelper()) rabi = Rabi(self.qubit, self.sched) fail_key = "fail_key" rabi.analysis.set_options(data_processor=DataProcessor(fail_key, [])) # pylint: disable=no-member rabi.set_run_options(shots=2) data = rabi.run(backend) result = data.analysis_results() self.assertEqual(data.status(), ExperimentStatus.ERROR) self.assertEqual(len(result), 0)
def test_frequency(self): """Test calibrations update from spectroscopy.""" qubit = 1 peak_offset = 5.0e6 backend = MockIQBackend( experiment_helper=SpectroscopyHelper(freq_offset=peak_offset), iq_cluster_centers=[((-1.0, -1.0), (1.0, 1.0))], iq_cluster_width=[0.2], ) backend._configuration.basis_gates = ["x"] backend._configuration.timing_constraints = {"granularity": 16} freq01 = backend.defaults().qubit_freq_est[qubit] frequencies = np.linspace(freq01 - 10.0e6, freq01 + 10.0e6, 21) spec = QubitSpectroscopy(qubit, frequencies) spec.set_run_options(meas_level=MeasLevel.CLASSIFIED) exp_data = spec.run(backend) self.assertExperimentDone(exp_data) result = exp_data.analysis_results(1) value = result.value.n self.assertTrue( freq01 + peak_offset - 2e6 < value < freq01 + peak_offset + 2e6) self.assertEqual(result.quality, "good") # Test the integration with the Calibrations cals = Calibrations.from_backend(FakeAthens()) self.assertNotEqual( cals.get_parameter_value(cals.__drive_freq_parameter__, qubit), value) Frequency.update(cals, exp_data) self.assertEqual( cals.get_parameter_value(cals.__drive_freq_parameter__, qubit), value)
def test_end_to_end(self): """Test a full experiment end to end.""" tol = 0.005 exp_helper = HalfAngleHelper() backend = MockIQBackend(exp_helper) for error in [-0.05, -0.02, 0.02, 0.05]: exp_helper.error = error hac = HalfAngle(0) exp_data = hac.run(backend) self.assertExperimentDone(exp_data) d_theta = exp_data.analysis_results(1).value.n self.assertTrue(abs(d_theta - error) < tol)
def test_end_to_end(self): """Test the drag experiment end to end.""" drag_experiment_helper = DragHelper(gate_name="Drag(xp)") backend = MockIQBackend(drag_experiment_helper) drag = RoughDrag(1, self.x_plus) expdata = drag.run(backend) self.assertExperimentDone(expdata) result = expdata.analysis_results(1) self.assertTrue( abs(result.value.n - backend.experiment_helper.ideal_beta) < self.test_tol) self.assertEqual(result.quality, "good") # Small leakage will make the curves very flat, in this case one should # rather increase beta. drag_experiment_helper.frequency = 0.0044 drag = RoughDrag(0, self.x_plus) exp_data = drag.run(backend) self.assertExperimentDone(exp_data) result = exp_data.analysis_results(1) self.assertTrue( abs(result.value.n - backend.experiment_helper.ideal_beta) < self.test_tol) self.assertEqual(result.quality, "good") # Large leakage will make the curves oscillate quickly. drag_experiment_helper.frequency = 0.04 drag = RoughDrag(1, self.x_plus, betas=np.linspace(-4, 4, 31)) # pylint: disable=no-member drag.set_run_options(shots=200) drag.analysis.set_options(p0={"beta": 1.8, "freq": 0.08}) exp_data = drag.run(backend) self.assertExperimentDone(exp_data) result = exp_data.analysis_results(1) meas_level = exp_data.metadata["meas_level"] self.assertEqual(meas_level, MeasLevel.CLASSIFIED) self.assertTrue( abs(result.value.n - backend.experiment_helper.ideal_beta) < self.test_tol) self.assertEqual(result.quality, "good")
def test_end_to_end(self, pi_ratio): """Test the experiment end to end.""" error = -np.pi * pi_ratio amp_exp = FineZXAmplitude((0, 1)) backend = MockIQBackend(FineAmpHelper(error, np.pi / 2, "szx")) expdata = amp_exp.run(backend) self.assertExperimentDone(expdata) result = expdata.analysis_results(1) d_theta = result.value.n tol = 0.04 self.assertAlmostEqual(d_theta, error, delta=tol) self.assertEqual(result.quality, "good")
def test_end_to_end_over_rotation(self, pi_ratio): """Test the experiment end to end.""" amp_exp = FineXAmplitude(0) amp_exp.set_transpile_options(basis_gates=["x", "sx"]) error = np.pi * pi_ratio backend = MockIQBackend(FineAmpHelper(error, np.pi, "x")) expdata = amp_exp.run(backend) self.assertExperimentDone(expdata) result = expdata.analysis_results(1) d_theta = result.value.n tol = 0.04 self.assertAlmostEqual(d_theta, error, delta=tol) self.assertEqual(result.quality, "good")
def test_user_schedule(self): """Test the user given schedule.""" amp = Parameter("my_double_amp") with pulse.build() as my_schedule: pulse.play(pulse.Drag(160, amp, 40, 10), pulse.DriveChannel(2)) pulse.play(pulse.Drag(160, amp, 40, 10), pulse.DriveChannel(2)) rabi = Rabi(2, self.sched) rabi.set_experiment_options(schedule=my_schedule, amplitudes=[0.5]) rabi.backend = MockIQBackend(RabiHelper()) circs = rabi.circuits() assigned_sched = my_schedule.assign_parameters({amp: 0.5}, inplace=False) self.assertEqual(circs[0].calibrations["Rabi"][((2, ), (0.5, ))], assigned_sched)
def test_kerneled_expdata_serialization(self): """Test experiment data and analysis data JSON serialization""" backend = MockIQBackend(MockIQReadoutAngleHelper(), iq_cluster_centers=[((-3.0, 3.0), (5.0, 5.0))]) exp = ReadoutAngle(0) exp.set_run_options(meas_level=MeasLevel.KERNELED, shots=1024) expdata = exp.run(backend).block_for_results() self.assertExperimentDone(expdata) # Checking serialization of the experiment data self.assertRoundTripSerializable(expdata, self.experiment_data_equiv) # Checking serialization of the analysis self.assertRoundTripSerializable(expdata.analysis_results(0), self.analysis_result_equiv)
def test_end_to_end(self): """Test that we can run on a mock backend and perform a fit. This test also checks that we can pickup frequency shifts with different signs. """ test_tol = 0.01 exp_helper = RamseyXYHelper() ramsey = RamseyXY(0) ramsey.backend = MockIQBackend(exp_helper) for freq_shift in [2e6, -3e6]: exp_helper.freq_shift = freq_shift test_data = ramsey.run() self.assertExperimentDone(test_data) meas_shift = test_data.analysis_results(1).value.n self.assertTrue( (meas_shift - freq_shift) < abs(test_tol * freq_shift))
def test_ef_rabi_end_to_end(self): """Test the EFRabi experiment end to end.""" test_tol = 0.01 backend = MockIQBackend(RabiHelper()) # Note that the backend is not sophisticated enough to simulate an e-f # transition so we run the test with a tiny frequency shift, still driving the e-g transition. rabi = EFRabi(self.qubit, self.sched) rabi.set_experiment_options(amplitudes=np.linspace(-0.95, 0.95, 21)) expdata = rabi.run(backend) self.assertExperimentDone(expdata) result = expdata.analysis_results(1) self.assertEqual(result.quality, "good") self.assertTrue( abs(result.value.n - backend.experiment_helper.rabi_rate()) < test_tol)
def test_nasty_data(self, freq, amp, offset, reps, betas, tol): """A set of tests for non-ideal data.""" backend = MockIQBackend( DragHelper(gate_name="Drag(xp)", frequency=freq, max_probability=amp, offset_probability=offset)) drag = RoughDrag(0, self.x_plus, betas=betas) drag.set_experiment_options(reps=reps) exp_data = drag.run(backend) self.assertExperimentDone(exp_data) result = exp_data.analysis_results("beta") self.assertTrue( abs(result.value.n - backend.experiment_helper.ideal_beta) < tol) self.assertEqual(result.quality, "good")