Skip to content

Commit

Permalink
Merge pull request #869 from qiboteam/fixdrag
Browse files Browse the repository at this point in the history
Hotfix for minus sign in DRAG shape
  • Loading branch information
stavros11 authored Apr 15, 2024
2 parents 3144c1d + c6945e6 commit 1db988e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/qibolab/pulses.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def eval(value: str) -> "PulseShape":
shape_name = re.findall(r"(\w+)", value)[0]
if shape_name not in globals():
raise ValueError(f"shape {value} not found")
shape_parameters = re.findall(r"[\w+\d\.\d]+", value)[1:]
shape_parameters = re.findall(r"[-\w+\d\.\d]+", value)[1:]
# TODO: create multiple tests to prove regex working correctly
return globals()[shape_name](*shape_parameters)

Expand Down
10 changes: 8 additions & 2 deletions tests/test_pulses.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,18 @@ def test_pulses_pulseshape_sampling_rate(shape):
def test_pulseshape_eval():
shape = PulseShape.eval("Rectangular()")
assert isinstance(shape, Rectangular)
shape = PulseShape.eval("Drag(5, 1)")
assert isinstance(shape, Drag)
with pytest.raises(ValueError):
shape = PulseShape.eval("Ciao()")


@pytest.mark.parametrize("rel_sigma,beta", [(5, 1), (5, -1), (3, -0.03), (4, 0.02)])
def test_drag_shape_eval(rel_sigma, beta):
shape = PulseShape.eval(f"Drag({rel_sigma}, {beta})")
assert isinstance(shape, Drag)
assert shape.rel_sigma == rel_sigma
assert shape.beta == beta


def test_raise_shapeiniterror():
shape = Rectangular()
with pytest.raises(ShapeInitError):
Expand Down

0 comments on commit 1db988e

Please sign in to comment.