Skip to content

Commit e6fbce2

Browse files
authored
misc: Remove default value in new_wamf1_control (#164)
1 parent 222c2e0 commit e6fbce2

File tree

2 files changed

+16
-26
lines changed

2 files changed

+16
-26
lines changed

qctrlopencontrols/driven_controls/predefined.py

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
import numpy as np
2525

26-
from ..exceptions import ArgumentsValueError
2726
from ..utils import check_arguments
2827
from .driven_control import DrivenControl
2928

@@ -871,9 +870,7 @@ def degrees_to_radians(angle_in_degrees):
871870
rabi_rates = [maximum_rabi_rate] * 9
872871
azimuthal_angles = total_angles[:, 1]
873872
detunings = [0] * 9
874-
durations = [
875-
rabi_rotation_ / maximum_rabi_rate for rabi_rotation_ in rabi_rotations
876-
]
873+
durations = [rabi_rotation / maximum_rabi_rate for rabi_rotation in rabi_rotations]
877874

878875
return DrivenControl(
879876
rabi_rates=rabi_rates,
@@ -886,9 +883,9 @@ def degrees_to_radians(angle_in_degrees):
886883

887884
def new_wamf1_control(
888885
rabi_rotation: float,
886+
maximum_rabi_rate: float,
889887
azimuthal_angle: float = 0.0,
890-
maximum_rabi_rate: float = 2.0 * np.pi,
891-
**kwargs
888+
name: Optional[str] = None,
892889
) -> DrivenControl:
893890
r"""
894891
Creates a first-order Walsh amplitude-modulated filter (WAMF1) driven control.
@@ -900,24 +897,18 @@ def new_wamf1_control(
900897
rabi_rotation : float
901898
The total Rabi rotation :math:`\theta` to be performed by the driven control. Must be either
902899
:math:`\pi/4`, :math:`\pi/2`, or :math:`\pi`.
903-
maximum_rabi_rate : float, optional
900+
maximum_rabi_rate : float
904901
The maximum Rabi frequency :math:`\Omega_{\rm max}` for the driven control.
905-
Defaults to :math:`2\pi`.
906902
azimuthal_angle : float, optional
907903
The azimuthal angle :math:`\phi` for the rotation. Defaults to 0.
908-
kwargs : dict
909-
Other keywords required to make a :py:obj:`DrivenControl`.
904+
name : str, optional
905+
An optional string to name the control. Defaults to ``None``.
910906
911907
Returns
912908
-------
913909
DrivenControl
914910
The driven control :math:`\{(\delta t_n, \Omega_n, \phi_n, \Delta_n)\}`.
915911
916-
Raises
917-
------
918-
ArgumentsValueError
919-
Raised when an argument is invalid.
920-
921912
Notes
922913
-----
923914
A WAMF1 [#]_ driven control consists of four control segments:
@@ -949,27 +940,26 @@ def new_wamf1_control(
949940
rabi_rotation=rabi_rotation, maximum_rabi_rate=maximum_rabi_rate
950941
)
951942

943+
check_arguments(
944+
np.any(np.isclose(rabi_rotation, [np.pi, np.pi / 2, np.pi / 4])),
945+
"rabi_rotation angle must be either pi, pi/2 or pi/4",
946+
{"rabi_rotation": rabi_rotation},
947+
)
948+
952949
if np.isclose(rabi_rotation, np.pi):
953950
theta_plus = np.pi
954951
theta_minus = np.pi / 2.0
955952
elif np.isclose(rabi_rotation, 0.5 * np.pi):
956953
theta_plus = np.pi * (2.5 + 0.65667825) / 4.0
957954
theta_minus = np.pi * (2.5 - 0.65667825) / 4.0
958-
elif np.isclose(rabi_rotation, 0.25 * np.pi):
955+
else:
959956
theta_plus = np.pi * (2.25 + 0.36256159) / 4.0
960957
theta_minus = np.pi * (2.25 - 0.36256159) / 4.0
961-
else:
962-
raise ArgumentsValueError(
963-
"rabi_rotation angle must be either pi, pi/2 or pi/4",
964-
{"rabi_rotation": rabi_rotation},
965-
)
966958

967959
rabi_rotations = [theta_plus, theta_minus, theta_minus, theta_plus]
968960
segment_duration = theta_plus / maximum_rabi_rate
969961

970-
rabi_rates = [
971-
rabi_rotation_ / segment_duration for rabi_rotation_ in rabi_rotations
972-
]
962+
rabi_rates = [rabi_rotation / segment_duration for rabi_rotation in rabi_rotations]
973963
azimuthal_angles = [azimuthal_angle] * 4
974964
detunings = [0] * 4
975965
durations = [segment_duration] * 4
@@ -979,7 +969,7 @@ def new_wamf1_control(
979969
azimuthal_angles=azimuthal_angles,
980970
detunings=detunings,
981971
durations=durations,
982-
**kwargs,
972+
name=name,
983973
)
984974

985975

tests/test_predefined_driven_controls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ def test_walsh_control():
449449
# Test that exceptions are raised upon wrong inputs for rabi_rotation
450450
# (WALSH control is only defined for pi/4, pi/2 and pi pulses)
451451
with pytest.raises(ArgumentsValueError):
452-
_ = new_wamf1_control(rabi_rotation=0.3)
452+
_ = new_wamf1_control(rabi_rotation=0.3, maximum_rabi_rate=np.pi)
453453

454454
# test pi rotation
455455
walsh_pi = new_wamf1_control(

0 commit comments

Comments
 (0)