Skip to content

Commit 40a3ca8

Browse files
nathlacroixStefania Balasiu
authored andcommitted
Integrate pull request feedback before merge with master
1 parent b272835 commit 40a3ca8

File tree

12 files changed

+33
-42
lines changed

12 files changed

+33
-42
lines changed

pycqed/analysis/measurement_analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1830,7 +1830,7 @@ def normalize_data_to_calibration_points(self, values, calsteps,
18301830
list(range(int(NoPts - int(self.NoCalPoints) / 2), NoPts))
18311831
ch_to_measure = \
18321832
0 if len(self.measured_values) == 1 else self.RO_channels[0]
1833-
print('ch to measure ', ch_to_measure)
1833+
log.debug('ch to measure ', ch_to_measure)
18341834
self.corr_data = a_tools.rotate_and_normalize_data_1ch(
18351835
self.measured_values[ch_to_measure],
18361836
cal_zero_points, cal_one_points)

pycqed/analysis_v2/readout_analysis.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ def recurse(node, thresholds_final, loc, mapping, feature_depth_path):
10551055
recurse(tree_.children_right[node], thresholds_final,
10561056
loc + [1], mapping, feature_depth_path)
10571057
else:
1058-
print(loc, tree_.value[node], feature_depth_path)
1058+
log.debug(loc, tree_.value[node], feature_depth_path)
10591059
if len(loc) < tree_.n_features:
10601060
log.warning(
10611061
"Location < n_features, threshold mapping might not be "
@@ -1231,7 +1231,7 @@ def plot_std(mean, cov, ax, n_std=1.0, facecolor='none', **kwargs):
12311231
# two-dimensionl dataset.
12321232
ell_radius_x = 1#np.sqrt(1 + pearson)
12331233
ell_radius_y = 1# np.sqrt(1 - pearson)
1234-
print(ell_radius_x)
1234+
12351235
ellipse = Ellipse((0, 0),
12361236
width=ell_radius_x * 2,
12371237
height=ell_radius_y * 2,
@@ -1462,7 +1462,6 @@ def probability_table(shots_of_qubits, observables, n_readouts):
14621462

14631463
table = np.zeros((n_readouts, len(observables)))
14641464

1465-
print(observables)
14661465

14671466
for qubit, results in shots_of_qubits.items():
14681467
res_e[qubit] = np.array(results).reshape((n_readouts, -1),
@@ -1487,9 +1486,6 @@ def probability_table(shots_of_qubits, observables, n_readouts):
14871486
else:
14881487
mask = np.logical_and(mask, res_g[qubit][seg])
14891488
table[readout_n, state_n] = np.count_nonzero(mask)
1490-
print(n_readouts)
1491-
print(n_shots)
1492-
print(np.sum(table))
14931489
return table*n_readouts/n_shots
14941490

14951491
@staticmethod

pycqed/analysis_v2/spectroscopy_analysis.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,6 @@ def find_f_RO(self, states):
10301030
self.proc_data_dict['spectra'],
10311031
self.proc_data_dict['plot_frequency'][0],
10321032
**self.options_dict.get('qutrit_fit_options', dict()))
1033-
print(states)
10341033
self.proc_data_dict["fit_raw_results"][key] = raw_results
10351034
else:
10361035
raise ValueError("{} states were given but method expects 1, "
@@ -1046,11 +1045,11 @@ def _find_f_RO_qutrit(spectra, freqs, sigma_init=0.01,
10461045
optimal_frequency = []
10471046
sigmas = [sigma_init]
10481047

1049-
logging.debug("###### Starting Analysis to find qutrit f_RO ######")
1048+
log.debug("###### Starting Analysis to find qutrit f_RO ######")
10501049

10511050
while ResonatorSpectroscopy_v2.update_sigma(avg_fidelities, sigmas, freqs,
10521051
optimal_frequency, n_iter, **kw):
1053-
logging.debug("Iteration {}".format(n_iter))
1052+
log.debug("Iteration {}".format(n_iter))
10541053
sigma = sigmas[-1]
10551054
if sigma in avg_fidelities.keys():
10561055
continue
@@ -1066,7 +1065,7 @@ def _find_f_RO_qutrit(spectra, freqs, sigma_init=0.01,
10661065
qutrit_key = "".join(list(spectra))
10671066

10681067

1069-
logging.debug("###### Finished Analysis. Optimal f_RO: {} ######"
1068+
log.debug("###### Finished Analysis. Optimal f_RO: {} ######"
10701069
.format(optimal_frequency[-1]))
10711070

10721071
return optimal_frequency[-1], raw_results if return_full else \
@@ -1098,7 +1097,7 @@ def update_sigma(avg_fidelities, sigmas, freqs,
10981097
fid, idx_width = ResonatorSpectroscopy_v2.fidelity_and_width(
10991098
avg_fidelities[sigma_current], target_fidelity)
11001099
width = idx_width * delta_freq
1101-
logging.debug("sigmas " + str(sigmas) + " width (MHz): "
1100+
log.debug("sigmas " + str(sigmas) + " width (MHz): "
11021101
+ str(width / 1e6))
11031102
f_opt = freqs[np.argmax(avg_fidelities[sigma_current])]
11041103
optimal_frequency.append(f_opt)
@@ -1121,7 +1120,7 @@ def update_sigma(avg_fidelities, sigmas, freqs,
11211120
sigma_new = \
11221121
10 ** (np.log10(sigma_current) + np.abs(log_diff))
11231122
msg = "Width > max_width, update sigma to: {}"
1124-
logging.debug(msg.format(sigma_new))
1123+
log.debug(msg.format(sigma_new))
11251124
sigmas.append(sigma_new)
11261125
elif fid < target_fidelity:
11271126
# sigma is too high, update higher bound
@@ -1131,7 +1130,7 @@ def update_sigma(avg_fidelities, sigmas, freqs,
11311130
sigma_new = 10 ** (np.log10(sigma_current) -
11321131
np.abs(log_diff) / 2)
11331132
msg = "Fidelity < target fidelity, update sigma to: {}"
1134-
logging.debug(msg.format(sigma_new))
1133+
log.debug(msg.format(sigma_new))
11351134
sigmas.append(sigma_new)
11361135

11371136
return continue_search

pycqed/analysis_v3/saving.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ def save_data(self, data_dict, savedir: str = None, savebase: str = None,
6262

6363
filepath = os.path.join(savedir, savebase + tstag + '.' + fmt)
6464
if self.verbose:
65-
print('Saving raw data to %s' % filepath)
65+
log.info('Saving raw data to %s' % filepath)
6666
with open(filepath, 'w') as file:
6767
json.dump(save_dict, file, cls=NumpyJsonEncoder, indent=4)
68-
print('Data saved to "{}".'.format(filepath))
68+
log.info('Data saved to "{}".'.format(filepath))
6969

7070

7171
def save_processed_data(self, key=None, overwrite=True):
@@ -99,7 +99,7 @@ def save_processed_data(self, key=None, overwrite=True):
9999
pass
100100

101101
if self.verbose:
102-
print('Saving fitting results to %s' % fn)
102+
log.info('Saving fitting results to %s' % fn)
103103

104104
with h5py.File(fn, 'a') as data_file:
105105
try:
@@ -136,7 +136,7 @@ def save_fit_results(data_dict, fit_res_dict, **params):
136136
pass
137137

138138
if params.get('verbose', False):
139-
print('Saving fitting results to %s' % fn)
139+
log.info('Saving fitting results to %s' % fn)
140140

141141
with h5py.File(fn, 'a') as data_file:
142142
try:
@@ -199,7 +199,7 @@ def save_figures(data_dict, figs, **params):
199199
pass
200200

201201
if params.get('verbose', False):
202-
print('Saving figures to %s' % savedir)
202+
log.info('Saving figures to %s' % savedir)
203203

204204
for key in key_list:
205205
if params.get('presentation_mode', False):

pycqed/instrument_drivers/meta_instrument/qubit_objects/QuDev_transmon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ def measure_randomized_benchmarking(
13211321
if classified_ro:
13221322
ba3.BaseDataAnalysis()
13231323
else:
1324-
print('Currently only classified ro is supported.')
1324+
log.error('Currently only classified ro is supported.')
13251325

13261326
def measure_transients(self, states=('g', 'e'), upload=True,
13271327
analyze=True, acq_length=4097/1.8e9,

pycqed/measurement/detector_functions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,6 @@ def process_data(self, data_raw):
13151315
# state_prob_mtx_list[i],
13161316
# self.get_values_function_kwargs.get(
13171317
# 'average', True), self.correlated)
1318-
print(classified_data.shape)
13191318
return classified_data.T
13201319

13211320
def classify_shots(self, data, classifier_params_list,
@@ -1352,7 +1351,7 @@ def classify_shots(self, data, classifier_params_list,
13521351
state_prob_mtx_list[i]).T @ clf_data.T
13531352
log.info('Data corrected based on state_prob_mtx.')
13541353
else:
1355-
print('not correcting data')
1354+
log.info('not correcting data')
13561355
clf_data = clf_data.T
13571356
# print(clf_data.shape)
13581357
classified_data[nr_states * i: nr_states * i + nr_states, :] = \

pycqed/measurement/measurement_control.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,8 +1268,6 @@ def get_datawriting_start_idx(self):
12681268
max_sweep_points = np.shape(self.get_sweep_points())[0]
12691269

12701270
start_idx = int(self.total_nr_acquired_values % max_sweep_points)
1271-
print('total_nr_acquired_values ', self.total_nr_acquired_values)
1272-
print('max_sweep_points ', max_sweep_points)
12731271
self.soft_iteration = int(
12741272
self.total_nr_acquired_values//max_sweep_points)
12751273

pycqed/measurement/multi_qubit_module.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,6 @@ def measure_multiplexed_readout(qubits, liveplot=False,
377377

378378
if analyse and thresholds is not None:
379379
channel_map = {qb.name: qb.int_log_det.value_names[0]+' '+qb.instr_uhf() for qb in qubits}
380-
print('MRO channel map ', channel_map)
381380
ra.Multiplexed_Readout_Analysis(options_dict=dict(
382381
n_readouts=(2 if preselection else 1) * 2 ** len(qubits),
383382
thresholds=thresholds,
@@ -429,7 +428,7 @@ def measure_arbitrary_sequence(qubits, sequence=None, sequence_function=None,
429428
detector_function=None, df_kwargs=dict(),
430429
sweep_function=awg_swf.SegmentHardSweep,
431430
sweep_points=None, temporary_values=(),
432-
exp_metadata=dict(), upload=True,
431+
exp_metadata=None, upload=True,
433432
analyze=True):
434433
"""
435434
Measures arbitrary sequence provided in input.
@@ -490,6 +489,9 @@ def measure_arbitrary_sequence(qubits, sequence=None, sequence_function=None,
490489
if label is None:
491490
label = f'{sequence.name}_{",".join(qb_names)}'
492491

492+
if exp_metadata is None:
493+
exp_metadata = {}
494+
493495
exp_metadata.update({'preparation_params': prep_params,
494496
# 'sweep_points': ,
495497
})
@@ -2188,7 +2190,7 @@ def measure_cphase(qbc, qbt, soft_sweep_params, cz_pulse_name,
21882190
n_per_state=n_cal_points_per_state)
21892191

21902192
if max_flux_length is not None:
2191-
print(f'max_flux_length = {max_flux_length*1e9:.2f} ns, set by user')
2193+
log.debug(f'max_flux_length = {max_flux_length*1e9:.2f} ns, set by user')
21922194

21932195
if prep_params is None:
21942196
prep_params = get_multi_qubit_prep_params(

pycqed/measurement/pulse_sequences/multi_qubit_tek_seq_elts.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,10 +1049,6 @@ def multi_parity_multi_round_seq(ancilla_qubit_names,
10491049
all_pulses += end_pulses
10501050
all_pulses += generate_mux_ro_pulse_list(qb_names, operation_dict)
10511051
all_pulsess.append(all_pulses)
1052-
if t==0:
1053-
from pprint import pprint
1054-
# pprint(all_pulses)
1055-
10561052

10571053

10581054
if prep_params is not None:
@@ -1088,13 +1084,13 @@ def multi_parity_multi_round_seq(ancilla_qubit_names,
10881084
repeat_dict[uhf] = (len(end_sequences),
10891085
(parity_loops, ROs), 1
10901086
)
1091-
print(repeat_dict)
1087+
log.debug(repeat_dict)
10921088

10931089
if upload:
10941090
ps.Pulsar.get_instance().program_awgs(seq, repeat_dict=repeat_dict)
10951091

10961092

1097-
print('sweep_points: ', seq.n_acq_elements())
1093+
log.debug('sweep_points: ', seq.n_acq_elements())
10981094
return seq, np.arange(seq.n_acq_elements())
10991095

11001096

pycqed/measurement/waveform_control/pulsar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def repeat_func(n, el_played, index, playback_strings, wave_definitions):
285285

286286

287287
if int(el_played) != int(el_total):
288-
print(el_played, ' is not ', el_total)
288+
log.error(el_played, ' is not ', el_total)
289289
raise ValueError('Check number of sequences in repeat pattern')
290290

291291

pycqed/measurement/waveform_control/segment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def resolve_timing(self):
169169

170170
ref_points = new_ref_points
171171
if len(visited_pulses) != len(self.unresolved_pulses):
172-
print(len(visited_pulses), len(self.unresolved_pulses))
172+
log.error(len(visited_pulses), len(self.unresolved_pulses))
173173
for unpulse in visited_pulses:
174174
if unpulse not in self.unresolved_pulses:
175175
print(unpulse)

pycqed/utilities/general.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from functools import reduce # forward compatibility for Python 3
1919
import operator
2020
import string
21+
log = logging.getLogger(__name__)
2122

2223
digs = string.digits + string.ascii_letters
2324

@@ -163,7 +164,7 @@ def load_settings_onto_instrument(instrument, load_from_instr=None,
163164
ins_group = sets_group[instrument_name]
164165
else:
165166
ins_group = sets_group[load_from_instr]
166-
print('Loaded Settings Successfully')
167+
log.info('Loaded Settings Successfully')
167168
success = True
168169
except:
169170
older_than = os.path.split(folder)[0][-8:] \
@@ -173,7 +174,7 @@ def load_settings_onto_instrument(instrument, load_from_instr=None,
173174
count += 1
174175

175176
if not success:
176-
print('Could not open settings for instrument "%s"' % (
177+
log.warning('Could not open settings for instrument "%s"' % (
177178
instrument_name))
178179
return False
179180

@@ -184,14 +185,14 @@ def load_settings_onto_instrument(instrument, load_from_instr=None,
184185
try:
185186
instrument.set(parameter, False)
186187
except:
187-
print('Could not set parameter: "%s" to "%s" for '
188+
log.error('Could not set parameter: "%s" to "%s" for '
188189
'instrument "%s"' % (
189190
parameter, value, instrument_name))
190191
elif value == 'True':
191192
try:
192193
instrument.set(parameter, True)
193194
except:
194-
print('Could not set parameter: "%s" to "%s" for '
195+
log.error('Could not set parameter: "%s" to "%s" for '
195196
'instrument "%s"' % (
196197
parameter, value, instrument_name))
197198
else:
@@ -204,7 +205,7 @@ def load_settings_onto_instrument(instrument, load_from_instr=None,
204205
try:
205206
instrument.set(parameter, int(value))
206207
except:
207-
print('Could not set parameter: "%s" to "%s" '
208+
log.error('Could not set parameter: "%s" to "%s" '
208209
'for instrument "%s"' % (
209210
parameter, value, instrument_name))
210211
else:
@@ -314,7 +315,7 @@ def load_settings(instrument,
314315
instrument.set(parameter,
315316
value)
316317
except Exception:
317-
print('Could not set parameter '
318+
log.error('Could not set parameter '
318319
'"%s" to "%s" '
319320
'for instrument "%s"' % (
320321
parameter, value,
@@ -335,7 +336,7 @@ def load_settings(instrument,
335336
count += 1
336337

337338
if not success:
338-
print('Could not open settings for instrument {}.'.format(
339+
log.error('Could not open settings for instrument {}.'.format(
339340
instrument_name))
340341
print()
341342
return

0 commit comments

Comments
 (0)