6
6
from qupulse .pulses .plotting import render
7
7
8
8
9
-
10
9
class MethodPulseTest (unittest .TestCase ):
11
10
def setUp (self ) -> None :
12
- pulse_method = lambda t : np .sin (.2 * t )
11
+ def pulse_method ( t ): return np .sin (.2 * t )
13
12
self .fpt = MethodPulseTemplate (pulse_method , duration = 100 , channel = 'A' )
14
13
15
14
@@ -31,18 +30,22 @@ def test_integral(self) -> None:
31
30
self .assertDictEqual (pulse .integral , {'default' : 30 })
32
31
pulse = MethodPulseTemplate (pulse_method = lambda t : np .sin (t ), duration = 30 )
33
32
self .assertDictEqual (pulse .integral , {'default' : ExpressionScalar (0.8457485501124153 )})
34
-
33
+
34
+ def test_get_serialization_data (self ):
35
+ s = self .fpt .get_serialization_data ()
36
+ self .assertEqual (s ['channel' ], 'A' )
37
+ self .assertIsInstance (s ['method' ], str )
38
+
35
39
36
40
class MethodPulseSequencingTest (MethodPulseTest ):
37
41
def test_build_waveform (self ) -> None :
38
42
wf = self .fpt .build_waveform ({}, channel_mapping = {'A' : 'B' })
39
43
self .assertEqual (wf .defined_channels , {'B' })
40
-
44
+
41
45
def test_sample (self ) -> None :
42
- times , values , _ = render (self .fpt .create_program (), sample_rate = 2 )
43
- np .testing .assert_almost_equal (values ['A' ], np .sin (.2 * np .arange (0 ,100.1 , .5 )))
46
+ times , values , _ = render (self .fpt .create_program (), sample_rate = 2 )
47
+ np .testing .assert_almost_equal (values ['A' ], np .sin (.2 * np .arange (0 , 100.1 , .5 )))
44
48
45
49
46
- if __name__ == '__main__' :
50
+ if __name__ == '__main__' :
47
51
unittest .main ()
48
-
0 commit comments