Skip to content

Commit b8079e0

Browse files
authored
misc: Fix code format (#220)
1 parent fd8b154 commit b8079e0

File tree

5 files changed

+48
-175
lines changed

5 files changed

+48
-175
lines changed

qctrlopencontrols/driven_controls/driven_control.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,7 @@ def resample(self, time_step: float, name: Optional[str] = None) -> "DrivenContr
351351
original duration.
352352
"""
353353
check_arguments(
354-
time_step > 0,
355-
"Time step must be positive.",
356-
{"time_step": time_step},
354+
time_step > 0, "Time step must be positive.", {"time_step": time_step}
357355
)
358356
check_arguments(
359357
time_step <= self.duration,

qctrlopencontrols/driven_controls/predefined.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,7 @@ def new_sk1_control(
300300

301301
rabi_rates = np.repeat(maximum_rabi_rate, 3)
302302
azimuthal_angles = np.asarray(
303-
[
304-
azimuthal_angle,
305-
azimuthal_angle - phi_p,
306-
azimuthal_angle + phi_p,
307-
]
303+
[azimuthal_angle, azimuthal_angle - phi_p, azimuthal_angle + phi_p]
308304
)
309305
detunings = np.repeat(0, 3)
310306
durations = np.asarray(
@@ -422,11 +418,7 @@ def degrees_to_radians(angle_in_degrees):
422418

423419
rabi_rates = np.repeat(maximum_rabi_rate, 3)
424420
azimuthal_angles = np.asarray(
425-
[
426-
azimuthal_angle + phi_1,
427-
azimuthal_angle + phi_2,
428-
azimuthal_angle + phi_3,
429-
]
421+
[azimuthal_angle + phi_1, azimuthal_angle + phi_2, azimuthal_angle + phi_3]
430422
)
431423
detunings = np.repeat(0, 3)
432424
durations = np.asarray(
@@ -1145,10 +1137,7 @@ def new_modulated_gaussian_control(
11451137
check_arguments(
11461138
duration > minimum_segment_duration,
11471139
"Total duration must be greater than minimum segment duration.",
1148-
{
1149-
"duration": duration,
1150-
"minimum_segment_duration": minimum_segment_duration,
1151-
},
1140+
{"duration": duration, "minimum_segment_duration": minimum_segment_duration},
11521141
)
11531142

11541143
# default spread of the gaussian shaped pulse as a fraction of its duration

qctrlopencontrols/dynamic_decoupling_sequences/predefined.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,9 @@ def _add_pre_post_rotations(
122122
if (preserves_10 and preserves_11) or (not preserves_10 and not preserves_11):
123123
final_azimuthal = np.pi
124124

125-
offsets = np.insert(
126-
offsets,
127-
[0, offsets.shape[0]],
128-
[0, duration],
129-
)
125+
offsets = np.insert(offsets, [0, offsets.shape[0]], [0, duration])
130126
rabi_rotations = np.insert(
131-
rabi_rotations,
132-
[0, rabi_rotations.shape[0]],
133-
[rabi_value, rabi_value],
127+
rabi_rotations, [0, rabi_rotations.shape[0]], [rabi_value, rabi_value]
134128
)
135129
azimuthal_angles = np.insert(
136130
azimuthal_angles,
@@ -714,11 +708,7 @@ def new_walsh_sequence(duration, paley_order, pre_post_rotation=False, name=None
714708

715709

716710
def new_quadratic_sequence(
717-
duration,
718-
inner_offset_count,
719-
outer_offset_count,
720-
pre_post_rotation=False,
721-
name=None,
711+
duration, inner_offset_count, outer_offset_count, pre_post_rotation=False, name=None
722712
):
723713
r"""
724714
Creates the quadratic sequence.

tests/test_predefined_driven_controls.py

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,7 @@ def test_scofulous_control():
167167

168168
# Construct SCROFULOUS controls for target rotations pi/4, pi/2 and pi
169169
scrofulous_pi = new_scrofulous_control(
170-
rabi_rotation=np.pi,
171-
azimuthal_angle=0.5,
172-
maximum_rabi_rate=2 * np.pi,
170+
rabi_rotation=np.pi, azimuthal_angle=0.5, maximum_rabi_rate=2 * np.pi
173171
)
174172

175173
pi_segments = np.vstack(
@@ -192,9 +190,7 @@ def test_scofulous_control():
192190
assert np.allclose(pi_segments, _pi_segments)
193191

194192
scrofulous_pi2 = new_scrofulous_control(
195-
rabi_rotation=np.pi / 2,
196-
azimuthal_angle=-0.5,
197-
maximum_rabi_rate=2 * np.pi,
193+
rabi_rotation=np.pi / 2, azimuthal_angle=-0.5, maximum_rabi_rate=2 * np.pi
198194
)
199195

200196
pi_on_2_segments = np.vstack(
@@ -217,9 +213,7 @@ def test_scofulous_control():
217213
assert np.allclose(pi_on_2_segments, _pi_on_2_segments)
218214

219215
scrofulous_pi4 = new_scrofulous_control(
220-
rabi_rotation=np.pi / 4,
221-
azimuthal_angle=0,
222-
maximum_rabi_rate=2 * np.pi,
216+
rabi_rotation=np.pi / 4, azimuthal_angle=0, maximum_rabi_rate=2 * np.pi
223217
)
224218

225219
pi_on_4_segments = np.vstack(
@@ -251,9 +245,7 @@ def test_corpse_in_scrofulous_control():
251245
"""
252246
# Test pi and pi/2 rotations
253247
cs_pi = new_corpse_in_scrofulous_control(
254-
rabi_rotation=np.pi,
255-
azimuthal_angle=0.5,
256-
maximum_rabi_rate=2 * np.pi,
248+
rabi_rotation=np.pi, azimuthal_angle=0.5, maximum_rabi_rate=2 * np.pi
257249
)
258250

259251
pi_segments = np.vstack(
@@ -277,9 +269,7 @@ def test_corpse_in_scrofulous_control():
277269
assert np.allclose(pi_segments, _pi_segments)
278270

279271
cs_pi_on_2 = new_corpse_in_scrofulous_control(
280-
rabi_rotation=np.pi / 2,
281-
azimuthal_angle=0.25,
282-
maximum_rabi_rate=np.pi,
272+
rabi_rotation=np.pi / 2, azimuthal_angle=0.25, maximum_rabi_rate=np.pi
283273
)
284274

285275
pi_on_2_segments = np.vstack(
@@ -367,9 +357,7 @@ def test_cinbb_control():
367357
Tests the segments of the CinBB (BB1 made up of CORPSEs) driven control.
368358
"""
369359
cinbb = new_corpse_in_bb1_control(
370-
rabi_rotation=np.pi / 3,
371-
azimuthal_angle=0.25,
372-
maximum_rabi_rate=np.pi,
360+
rabi_rotation=np.pi / 3, azimuthal_angle=0.25, maximum_rabi_rate=np.pi
373361
)
374362

375363
segments = np.vstack(
@@ -390,9 +378,7 @@ def test_cinbb_control():
390378
assert np.allclose(segments, _segments)
391379

392380
cinbb = new_corpse_in_bb1_control(
393-
rabi_rotation=np.pi / 5,
394-
azimuthal_angle=-0.25,
395-
maximum_rabi_rate=np.pi,
381+
rabi_rotation=np.pi / 5, azimuthal_angle=-0.25, maximum_rabi_rate=np.pi
396382
)
397383

398384
segments = np.vstack(
@@ -418,9 +404,7 @@ def test_cinsk1_control():
418404
Tests the segments of the CinSK1 (SK1 made up of CORPSEs) driven control.
419405
"""
420406
cinsk = new_corpse_in_sk1_control(
421-
rabi_rotation=np.pi / 2,
422-
azimuthal_angle=0.5,
423-
maximum_rabi_rate=2 * np.pi,
407+
rabi_rotation=np.pi / 2, azimuthal_angle=0.5, maximum_rabi_rate=2 * np.pi
424408
)
425409

426410
segments = np.vstack(
@@ -440,9 +424,7 @@ def test_cinsk1_control():
440424
assert np.allclose(segments, _segments)
441425

442426
cinsk = new_corpse_in_sk1_control(
443-
rabi_rotation=2 * np.pi,
444-
azimuthal_angle=-0.5,
445-
maximum_rabi_rate=2 * np.pi,
427+
rabi_rotation=2 * np.pi, azimuthal_angle=-0.5, maximum_rabi_rate=2 * np.pi
446428
)
447429

448430
segments = np.vstack(
@@ -473,9 +455,7 @@ def test_walsh_control():
473455

474456
# test pi rotation
475457
walsh_pi = new_wamf1_control(
476-
rabi_rotation=np.pi,
477-
azimuthal_angle=-0.35,
478-
maximum_rabi_rate=2 * np.pi,
458+
rabi_rotation=np.pi, azimuthal_angle=-0.35, maximum_rabi_rate=2 * np.pi
479459
)
480460

481461
pi_segments = np.vstack(
@@ -500,9 +480,7 @@ def test_walsh_control():
500480

501481
# test pi/2 rotation
502482
walsh_pi_on_2 = new_wamf1_control(
503-
rabi_rotation=np.pi / 2.0,
504-
azimuthal_angle=0.57,
505-
maximum_rabi_rate=2 * np.pi,
483+
rabi_rotation=np.pi / 2.0, azimuthal_angle=0.57, maximum_rabi_rate=2 * np.pi
506484
)
507485

508486
pi_on_2_segments = np.vstack(
@@ -527,9 +505,7 @@ def test_walsh_control():
527505

528506
# test pi/4 rotation
529507
walsh_pi_on_4 = new_wamf1_control(
530-
rabi_rotation=np.pi / 4.0,
531-
azimuthal_angle=-0.273,
532-
maximum_rabi_rate=2 * np.pi,
508+
rabi_rotation=np.pi / 4.0, azimuthal_angle=-0.273, maximum_rabi_rate=2 * np.pi
533509
)
534510
pi_on_4_segments = np.vstack(
535511
(
@@ -698,8 +674,7 @@ def test_modulated_gaussian_control_give_identity_gate():
698674
[
699675
np.cos(d * v) * np.eye(2) + 1j * np.sin(d * v) * SIGMA_X
700676
for d, v in zip(
701-
p.durations,
702-
p.rabi_rates * np.exp(1j * p.azimuthal_angles),
677+
p.durations, p.rabi_rates * np.exp(1j * p.azimuthal_angles)
703678
)
704679
]
705680
)

0 commit comments

Comments
 (0)