예제 #1
0
    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)
예제 #2
0
    def test_update_with_failed_analysis(self):
        """Test that calibration update handles analysis producing no results

        Here we test that the experiment does not raise an unexpected exception
        or hang indefinitely. Since there are no analysis results, we expect
        that the calibration update will result in an ERROR status.
        """
        backend = MockIQBackend(RamseyXYHelper(freq_shift=0))

        class NoResults(BaseAnalysis):
            """Simple analysis class that generates no results"""
            def _run_analysis(self, experiment_data):
                return ([], [])

        expt = FrequencyCal(0, self.cals, backend, auto_update=True)
        expt.analysis = NoResults()
        expdata = expt.run()
        expdata.block_for_results(timeout=3)
        self.assertEqual(expdata.analysis_status(), AnalysisStatus.ERROR)
예제 #3
0
 def test_freqcal_roundtrip_serializable(self):
     """Test round trip JSON serialization"""
     exp = FrequencyCal(0, self.cals)
     self.assertRoundTripSerializable(exp, self.json_equiv)
예제 #4
0
 def test_cal_experiment_config(self):
     """Test FrequencyCal config roundtrips"""
     exp = FrequencyCal(0, self.cals)
     loaded_exp = FrequencyCal.from_config(exp.config())
     self.assertNotEqual(exp, loaded_exp)
     self.assertTrue(self.json_equiv(exp, loaded_exp))