Skip to content

Commit

Permalink
fixing test
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanbasov committed Jul 20, 2023
1 parent dec5827 commit 13022c5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
17 changes: 15 additions & 2 deletions azure-quantum/azure/quantum/target/microsoft/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _check_error_rate_or_process_and_readout(name, value):
class MeasurementErrorRate(AutoValidatingParams):
process: float = field(metadata={"validate": _check_error_rate})
readout: float = field(metadata={"validate": _check_error_rate})


@dataclass
class MicrosoftEstimatorQubitParams(AutoValidatingParams):
Expand Down Expand Up @@ -118,6 +118,19 @@ def post_validation(self, result):
if self.one_qubit_gate_time is None:
raise LookupError("one_qubit_gate_time must be set")

def as_dict(self, validate=True) -> Dict[str, Any]:
qubit_params = super().as_dict(validate)
if len(qubit_params) != 0:
if isinstance(self.one_qubit_measurement_error_rate, MeasurementErrorRate):
qubit_params["oneQubitMeasurementErrorRate"] = \
self.one_qubit_measurement_error_rate.as_dict(validate)

if isinstance(self.two_qubit_joint_measurement_error_rate, MeasurementErrorRate):
qubit_params["twoQubitJointMeasurementErrorRate"] = \
self.two_qubit_joint_measurement_error_rate.as_dict(validate)

return qubit_params


@dataclass
class MicrosoftEstimatorQecScheme(AutoValidatingParams):
Expand Down Expand Up @@ -203,7 +216,7 @@ def post_validation(self, result):
if self.logical_qubit_specification_first_round_override is not None:
self.logical_qubit_specification_first_round_override.post_validation(result)

def as_dict(self, validate):
def as_dict(self, validate=True) -> Dict[str, Any]:
specification_dict = super().as_dict(validate)
if len(specification_dict) != 0:
if self.physical_qubit_specification is not None:
Expand Down
14 changes: 12 additions & 2 deletions azure-quantum/tests/unit/test_microsoft_qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,21 @@ def test_estimator_params_validation_measurement_error_rates_valid(self):
params.qubit_params.t_gate_error_rate = 0.03
params.qubit_params.t_gate_time = "10 ns"
params.qubit_params.idle_error_rate = 0.02
params.one_qubit_measurement_error_rate = 0.01
params.qubit_params.one_qubit_measurement_error_rate = 0.01
params.qubit_params.two_qubit_joint_measurement_error_rate = \
MeasurementErrorRate(process = 0.02, readout = 0.03)

params.as_dict()
assert params.as_dict() == {
"errorBudget": 0.1,
"qubitParams": {"name": "qubit_gate_ns_e3",
"instructionSet": "gate_based",
"tGateErrorRate": 0.03,
"tGateTime": "10 ns",
"idleErrorRate": 0.02,
"oneQubitMeasurementErrorRate": 0.01,
"twoQubitJointMeasurementErrorRate":
{"process": 0.02, "readout": 0.03}}
}


def test_estimator_error_budget_float(self):
Expand Down

0 comments on commit 13022c5

Please sign in to comment.