Ejemplo n.º 1
0
    def setUp(self):
        """Initialize some cals."""
        super().setUp()

        library = FixedFrequencyTransmon()
        self.cals = Calibrations.from_backend(FakeArmonk(),
                                              libraries=[library])
    def test_frequency(self):
        """Test calibrations update from spectroscopy."""

        qubit = 1
        peak_offset = 5.0e6
        backend = SpectroscopyBackend(line_width=2e6, freq_offset=peak_offset)
        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_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)