Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single shot refactoring #1086

Draft
wants to merge 11 commits into
base: 0.1
Choose a base branch
from
1 change: 1 addition & 0 deletions src/qibocal/auto/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def _to_npz(self, path: Path, filename: str):
def _to_json(self, path: Path, filename: str):
"""Helper function to dump to json."""
if self.params:
print("AAAAAA", self.params)
(path / f"{filename}.json").write_text(
json.dumps(serialize(self.params), indent=4)
)
Expand Down
12 changes: 7 additions & 5 deletions src/qibocal/fitting/classifier/qubit_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ class QubitFit:
probability_error: float = None
effective_qubit_temperature: float = None

def fit(self, iq_coordinates: list, states: list):
def fit(self, i_coordinates: list, q_coordinates: list, states: list):
r"""Evaluate the model's parameters given the
`iq_coordinates` and their relative ``states`
(reference: <https://arxiv.org/abs/1004.4323>).
"""
iq_coordinates = np.stack((i_coordinates, q_coordinates), axis=-1)
iq_state1 = iq_coordinates[(states == 1)]
iq_state0 = iq_coordinates[(states == 0)]
self.iq_mean0 = np.mean(iq_state0, axis=0)
self.iq_mean1 = np.mean(iq_state1, axis=0)

vector01 = self.iq_mean1 - self.iq_mean0
iq_mean0 = np.mean(iq_state0, axis=0)
iq_mean1 = np.mean(iq_state1, axis=0)
vector01 = iq_mean1 - iq_mean0
self.angle = -1 * atan2(vector01[1], vector01[0])

# rotate
Expand Down Expand Up @@ -115,6 +115,8 @@ def fit(self, iq_coordinates: list, states: list):
self.probability_error = np.sum(np.absolute(states - predictions)) / len(
predictions
)
self.iq_mean0 = iq_mean0.tolist()
self.iq_mean1 = iq_mean1.tolist()

def effective_temperature(self, predictions, qubit_frequency: float):
"""Calculate effective qubit temperature."""
Expand Down
1 change: 0 additions & 1 deletion src/qibocal/fitting/classifier/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ def train_qubit(
hpars_list.append(hyperpars)
classifier.dump_hyper(hyperpars)
model = classifier.create_model(hyperpars)

results, _y_pred, model, _ = benchmarking(
model, x_train, y_train, x_test, y_test
)
Expand Down
Loading