Skip to content

Commit

Permalink
Use nullable integer
Browse files Browse the repository at this point in the history
  • Loading branch information
nkanazawa1989 committed Oct 27, 2023
1 parent 8036b14 commit 1671078
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
13 changes: 2 additions & 11 deletions qiskit_experiments/curve_analysis/curve_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,7 @@ def _run_curve_fit(
# Create convenient function to compute residual of the models.
partial_residuals = []
valid_uncertainty = np.all(np.isfinite(curve_data.yerr.to_numpy()))
for i, sub_data in list(curve_data.groupby("model_id")):
try:
m_id = int(i)
except ValueError:
# Probably invalid data which doesn't belong to any fit model.
continue
for m_id, sub_data in list(curve_data.groupby("model_id")):
if valid_uncertainty:
nonzero_yerr = np.where(
np.isclose(sub_data.yerr, 0.0),
Expand Down Expand Up @@ -516,11 +511,7 @@ def _run_analysis(
fit_curves = []
formatted = curve_data.filter(like="formatted", axis="index")
columns = list(curve_data.columns)
for i, sub_data in list(formatted.groupby("model_id")):
try:
m_id = int(i)
except ValueError:
continue
for m_id, sub_data in list(formatted.groupby("model_id")):
name = self._models[m_id]._name
xval = sub_data.xval.to_numpy()
if len(xval) == 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from typing import List, Union

import lmfit
import pandas as pd
import numpy as np
from uncertainties import unumpy as unp

Expand Down Expand Up @@ -489,7 +490,7 @@ def _format_data(

# Invalidate model_id because these are index of raw Ramsey curves.
# Fit models are defined based on the phase data.
formatted_data.model_id = "n/a"
formatted_data.model_id = pd.NA
out = formatted_data.append_list_values(
other=phase_data,
prefix="formatted",
Expand Down

0 comments on commit 1671078

Please sign in to comment.