Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ def _build_schedules(self, basis_gates: Set[str]) -> Dict[str, ScheduleBlock]:
are the corresponding schedules.
"""

@property
def config(self) -> Dict[str, Any]:
"""Return the settings used to initialize the library."""

Expand Down Expand Up @@ -169,7 +168,7 @@ def from_config(cls, config: Dict) -> "BasisGateLibrary":

def __json_encode__(self):
"""Convert to format that can be JSON serialized."""
return self.config
return self.config()

@classmethod
def __json_decode__(cls, value: Dict[str, Any]) -> "BasisGateLibrary":
Expand Down
4 changes: 1 addition & 3 deletions qiskit_experiments/framework/base_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class method of the appropriate experiment.
run_options: Dict[str, Any] = dataclasses.field(default_factory=dict)
version: str = __version__

@property
def experiment(self) -> "BaseExperiment":
"""Return the experiment constructed from this config.

Expand Down Expand Up @@ -187,7 +186,6 @@ def copy(self) -> "BaseExperiment":
ret._analysis_options = copy.copy(self._analysis_options)
return ret

@property
def config(self) -> ExperimentConfig:
"""Return the config dataclass for this experiment"""
args = tuple(getattr(self, "__init_args__", OrderedDict()).values())
Expand Down Expand Up @@ -515,7 +513,7 @@ def _add_job_metadata(self, metadata: Dict[str, Any], jobs: BaseJob, **run_optio

def __json_encode__(self):
"""Convert to format that can be JSON serialized"""
return self.config
return self.config()

@classmethod
def __json_decode__(cls, value):
Expand Down
4 changes: 2 additions & 2 deletions test/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def assertRoundTripSerializable(self, obj: Any, check_func: Optional[Callable] =
def experiments_equiv(exp1, exp2) -> bool:
"""Check if two experiments are equivalent by comparing their configs"""
# pylint: disable = too-many-boolean-expressions, too-many-return-statements
config1 = exp1.config
config2 = exp2.config
config1 = exp1.config()
config2 = exp2.config()
try:
if config1 == config2:
return True
Expand Down
4 changes: 2 additions & 2 deletions test/calibration/experiments/test_drag.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def test_update(self):
def test_dragcal_experiment_config(self):
"""Test RoughDragCal config can round trip"""
exp = RoughDragCal(0, self.cals, backend=self.backend)
loaded_exp = RoughDragCal.from_config(exp.config)
loaded_exp = RoughDragCal.from_config(exp.config())
self.assertNotEqual(exp, loaded_exp)
self.assertTrue(self.experiments_equiv(exp, loaded_exp))

Expand All @@ -179,7 +179,7 @@ def test_drag_experiment_config(self):
with pulse.build(name="xp") as sched:
pulse.play(pulse.Drag(160, 0.5, 40, Parameter("β")), pulse.DriveChannel(0))
exp = RoughDrag(0, backend=self.backend, schedule=sched)
loaded_exp = RoughDrag.from_config(exp.config)
loaded_exp = RoughDrag.from_config(exp.config())
self.assertNotEqual(exp, loaded_exp)
self.assertTrue(self.experiments_equiv(exp, loaded_exp))

Expand Down
2 changes: 1 addition & 1 deletion test/calibration/experiments/test_fine_amplitude.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def test_run_sx_cal(self):
def test_experiment_config(self):
"""Test converting to and from config works"""
exp = FineSXAmplitudeCal(0, self.cals, "sx")
loaded_exp = FineSXAmplitudeCal.from_config(exp.config)
loaded_exp = FineSXAmplitudeCal.from_config(exp.config())
self.assertNotEqual(exp, loaded_exp)
self.assertTrue(self.experiments_equiv(exp, loaded_exp))

Expand Down
8 changes: 4 additions & 4 deletions test/calibration/experiments/test_fine_drag.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ def test_end_to_end_no_schedule(self):
def test_experiment_config(self):
"""Test converting to and from config works"""
exp = FineDrag(0, Gate("Drag", num_qubits=1, params=[]))
config = exp.config
config = exp.config()
loaded_exp = FineDrag.from_config(config)
self.assertNotEqual(exp, loaded_exp)
self.assertEqual(config, loaded_exp.config)
self.assertEqual(config, loaded_exp.config())


class TestFineDragCal(QiskitExperimentsTestCase):
Expand All @@ -100,10 +100,10 @@ def setUp(self):
def test_experiment_config(self):
"""Test converting to and from config works"""
exp = FineDragCal(0, self.cals, schedule_name="x")
config = exp.config
config = exp.config()
loaded_exp = FineDragCal.from_config(config)
self.assertNotEqual(exp, loaded_exp)
self.assertEqual(config, loaded_exp.config)
self.assertEqual(config, loaded_exp.config())

def test_update_cals(self):
"""Test that the calibrations are updated."""
Expand Down
4 changes: 2 additions & 2 deletions test/calibration/experiments/test_rabi.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_wrong_processor(self):
def test_experiment_config(self):
"""Test converting to and from config works"""
exp = Rabi(0, self.sched)
loaded_exp = Rabi.from_config(exp.config)
loaded_exp = Rabi.from_config(exp.config())
self.assertNotEqual(exp, loaded_exp)
self.assertTrue(self.experiments_equiv(exp, loaded_exp))

Expand Down Expand Up @@ -165,7 +165,7 @@ def test_ef_rabi_circuit(self):
def test_experiment_config(self):
"""Test converting to and from config works"""
exp = EFRabi(0, self.sched)
loaded_exp = EFRabi.from_config(exp.config)
loaded_exp = EFRabi.from_config(exp.config())
self.assertNotEqual(exp, loaded_exp)
self.assertTrue(self.experiments_equiv(exp, loaded_exp))

Expand Down
4 changes: 2 additions & 2 deletions test/calibration/experiments/test_ramsey_xy.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_update_calibrations(self):
def test_ramseyxy_experiment_config(self):
"""Test RamseyXY config roundtrips"""
exp = RamseyXY(0)
loaded_exp = RamseyXY.from_config(exp.config)
loaded_exp = RamseyXY.from_config(exp.config())
self.assertNotEqual(exp, loaded_exp)
self.assertTrue(self.experiments_equiv(exp, loaded_exp))

Expand All @@ -82,7 +82,7 @@ def test_ramseyxy_roundtrip_serializable(self):
def test_cal_experiment_config(self):
"""Test FrequencyCal config roundtrips"""
exp = FrequencyCal(0, self.cals)
loaded_exp = FrequencyCal.from_config(exp.config)
loaded_exp = FrequencyCal.from_config(exp.config())
self.assertNotEqual(exp, loaded_exp)
self.assertTrue(self.experiments_equiv(exp, loaded_exp))

Expand Down
4 changes: 2 additions & 2 deletions test/calibration/experiments/test_rough_amplitude.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ def test_update(self):
def test_experiment_config(self):
"""Test converting to and from config works"""
exp = RoughXSXAmplitudeCal(0, self.cals)
config = exp.config
config = exp.config()
loaded_exp = RoughXSXAmplitudeCal.from_config(config)
self.assertNotEqual(exp, loaded_exp)
self.assertEqual(config, loaded_exp.config)
self.assertEqual(config, loaded_exp.config())


class TestSpecializations(QiskitExperimentsTestCase):
Expand Down
2 changes: 1 addition & 1 deletion test/calibration/experiments/test_rough_frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ def test_experiment_config(self):
cals = BackendCalibrations(FakeArmonk())
frequencies = [1, 2, 3]
exp = RoughFrequencyCal(0, cals, frequencies)
loaded_exp = RoughFrequencyCal.from_config(exp.config)
loaded_exp = RoughFrequencyCal.from_config(exp.config())
self.assertNotEqual(exp, loaded_exp)
self.assertTrue(self.experiments_equiv(exp, loaded_exp))
2 changes: 1 addition & 1 deletion test/calibration/test_setup_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def test_serialization(self):
link_parameters=False,
)

lib2 = FixedFrequencyTransmon.from_config(lib1.config)
lib2 = FixedFrequencyTransmon.from_config(lib1.config())

self.assertEqual(lib2.basis_gates, lib1.basis_gates)

Expand Down
2 changes: 1 addition & 1 deletion test/quantum_volume/test_qv.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def test_qv_success(self):
def test_experiment_config(self):
"""Test converting to and from config works"""
exp = QuantumVolume([0, 1, 2], seed=42)
loaded_exp = QuantumVolume.from_config(exp.config)
loaded_exp = QuantumVolume.from_config(exp.config())
self.assertNotEqual(exp, loaded_exp)
self.assertTrue(self.experiments_equiv(exp, loaded_exp))

Expand Down
4 changes: 2 additions & 2 deletions test/randomized_benchmarking/test_rb.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def test_input(self):
def test_experiment_config(self):
"""Test converting to and from config works"""
exp = StandardRB([0, 1], lengths=[10, 20, 30, 40], num_samples=10)
loaded_exp = StandardRB.from_config(exp.config)
loaded_exp = StandardRB.from_config(exp.config())
self.assertNotEqual(exp, loaded_exp)
self.assertTrue(self.experiments_equiv(exp, loaded_exp))

Expand Down Expand Up @@ -261,7 +261,7 @@ def test_non_clifford_interleaved_element(self):
def test_experiment_config(self):
"""Test converting to and from config works"""
exp = InterleavedRB(CXGate(), [0, 1], lengths=[10, 20, 30, 40], num_samples=10)
loaded_exp = InterleavedRB.from_config(exp.config)
loaded_exp = InterleavedRB.from_config(exp.config())
self.assertNotEqual(exp, loaded_exp)
self.assertTrue(self.experiments_equiv(exp, loaded_exp))

Expand Down
2 changes: 1 addition & 1 deletion test/test_cross_resonance_hamiltonian.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def test_experiment_config(self):
sigma=20,
risefall=2,
)
loaded_exp = cr_hamiltonian.CrossResonanceHamiltonian.from_config(exp.config)
loaded_exp = cr_hamiltonian.CrossResonanceHamiltonian.from_config(exp.config())
self.assertNotEqual(exp, loaded_exp)
self.assertTrue(self.experiments_equiv(exp, loaded_exp))

Expand Down
4 changes: 2 additions & 2 deletions test/test_half_angle.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_circuits(self):
def test_experiment_config(self):
"""Test converting to and from config works"""
exp = HalfAngle(1)
config = exp.config
config = exp.config()
loaded_exp = HalfAngle.from_config(config)
self.assertNotEqual(exp, loaded_exp)
self.assertEqual(config, loaded_exp.config)
self.assertEqual(config, loaded_exp.config())
2 changes: 1 addition & 1 deletion test/test_qubit_spectroscopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def test_spectroscopy12_end2end_classified(self):
def test_experiment_config(self):
"""Test converting to and from config works"""
exp = QubitSpectroscopy(1, np.linspace(100, 150, 20), unit="MHz")
loaded_exp = QubitSpectroscopy.from_config(exp.config)
loaded_exp = QubitSpectroscopy.from_config(exp.config())
self.assertNotEqual(exp, loaded_exp)
self.assertTrue(self.experiments_equiv(exp, loaded_exp))

Expand Down
2 changes: 1 addition & 1 deletion test/test_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def test_t1_low_quality(self):
def test_experiment_config(self):
"""Test converting to and from config works"""
exp = T1(0, [1, 2, 3, 4, 5], unit="s")
loaded_exp = T1.from_config(exp.config)
loaded_exp = T1.from_config(exp.config())
self.assertNotEqual(exp, loaded_exp)
self.assertTrue(self.experiments_equiv(exp, loaded_exp))

Expand Down
2 changes: 1 addition & 1 deletion test/test_t2ramsey.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def test_t2ramsey_concat_2_experiments(self):
def test_experiment_config(self):
"""Test converting to and from config works"""
exp = T2Ramsey(0, [1, 2, 3, 4, 5], unit="s")
loaded_exp = T2Ramsey.from_config(exp.config)
loaded_exp = T2Ramsey.from_config(exp.config())
self.assertNotEqual(exp, loaded_exp)
self.assertTrue(self.experiments_equiv(exp, loaded_exp))

Expand Down
4 changes: 2 additions & 2 deletions test/test_tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def test_parallel_exp(self):
def test_experiment_config(self):
"""Test converting to and from config works"""
exp = StateTomography(QuantumCircuit(3), measurement_qubits=[0, 2], qubits=[5, 7, 1])
loaded_exp = StateTomography.from_config(exp.config)
loaded_exp = StateTomography.from_config(exp.config())
self.assertNotEqual(exp, loaded_exp)
self.assertTrue(self.experiments_equiv(exp, loaded_exp))

Expand Down Expand Up @@ -481,7 +481,7 @@ def test_parallel_exp(self):
def test_experiment_config(self):
"""Test converting to and from config works"""
exp = ProcessTomography(teleport_circuit(), measurement_qubits=[2], preparation_qubits=[0])
loaded_exp = ProcessTomography.from_config(exp.config)
loaded_exp = ProcessTomography.from_config(exp.config())
self.assertNotEqual(exp, loaded_exp)
self.assertTrue(self.experiments_equiv(exp, loaded_exp))

Expand Down