Repository: qiboteam/qibolab

Issue:
Sign of pulse parameters is not deserialized properly
```py
pulse = Pulse(0, 40, 0.3, int(4e9), 0.0, shape="Drag(5, -0.02)")
print(pulse)
```
gives
```
Pulse(0, 40, 0.3, 4_000_000_000, 0, Drag(5, 0.02), None, PulseType.DRIVE, 0)
```
so `-0.02` is converted to `0.02`. I am not sure if this has any practical consequence in this case.

I found this while working on #789 for 0.2, but then I realized that it also exists for 0.1. I am guessing it will be solved by #818 where the ugly `eval` will be dropped, so I would even postpone for 0.2. @alecandido if you agree, we can put this directly to the 0.2 milestone.

Discussion:

Patch:
diff --git a/src/qibolab/pulses.py b/src/qibolab/pulses.py
index 01f8797e..a20d7a8b 100644
--- a/src/qibolab/pulses.py
+++ b/src/qibolab/pulses.py
@@ -218,7 +218,7 @@ class PulseShape(ABC):
         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)
 


Test patch:
diff --git a/tests/test_pulses.py b/tests/test_pulses.py
index 8135b3c7..9939b8fa 100644
--- a/tests/test_pulses.py
+++ b/tests/test_pulses.py
@@ -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):