Debian Codegraph @

tests/instruments/yokogawa/test_aq6370d.py

raw
1 import pytest
2
3 from pymeasure.instruments.yokogawa.aq6370series import AQ6370D
4 from pymeasure.test import expected_protocol
5
6
7 def test_init():
8 with expected_protocol(
9 AQ6370D,
10 [],
11 ):
12 pass # Verify the expected communication.
13
14
15 def test_automatic_sample_number_setter():
16 with expected_protocol(
17 AQ6370D,
18 [(b":SENSe:SWEep:POINts:AUTO 0", None)],
19 ) as inst:
20 inst.automatic_sample_number = False
21
22
23 def test_level_position_getter():
24 with expected_protocol(
25 AQ6370D,
26 [(b":DISPlay:TRACe:Y1:RPOSition?", b"8\n")],
27 ) as inst:
28 assert inst.level_position == 8
29
30
31 def test_reference_level_setter():
32 with expected_protocol(
33 AQ6370D,
34 [(b":DISPlay:TRACe:Y1:SCALe:RLEVel -10", None)],
35 ) as inst:
36 inst.reference_level = -10
37
38
39 def test_reference_level_getter():
40 with expected_protocol(
41 AQ6370D,
42 [(b":DISPlay:TRACe:Y1:SCALe:RLEVel?", b"-1.00000000E+001\n")],
43 ) as inst:
44 assert inst.reference_level == -10.0
45
46
47 def test_resolution_bandwidth_setter():
48 with expected_protocol(
49 AQ6370D,
50 [(b":SENSe:BWIDth:RESolution 1e-09", None)],
51 ) as inst:
52 inst.resolution_bandwidth = 1e-09
53
54
55 def test_sample_number_setter():
56 with expected_protocol(
57 AQ6370D,
58 [(b":SENSe:SWEep:POINts 101", None)],
59 ) as inst:
60 inst.sample_number = 101
61
62
63 def test_sweep_mode_setter():
64 with expected_protocol(
65 AQ6370D,
66 [(b":INITiate:SMODe 2", None)],
67 ) as inst:
68 inst.sweep_mode = "REPEAT"
69
70
71 def test_sweep_mode_getter():
72 with expected_protocol(
73 AQ6370D,
74 [(b":INITiate:SMODe?", b"2\n")],
75 ) as inst:
76 assert inst.sweep_mode == "REPEAT"
77
78
79 @pytest.mark.parametrize(
80 "comm_pairs, value",
81 (
82 ([(b":SENSe:SWEep:SPEed 0", None)], "1x"),
83 ([(b":SENSe:SWEep:SPEed 1", None)], "2x"),
84 ),
85 )
86 def test_sweep_speed_setter(comm_pairs, value):
87 with expected_protocol(
88 AQ6370D,
89 comm_pairs,
90 ) as inst:
91 inst.sweep_speed = value
92
93
94 @pytest.mark.parametrize(
95 "comm_pairs, value",
96 (
97 ([(b":SENSe:SWEep:SPEed?", b"0\n")], "1x"),
98 ([(b":SENSe:SWEep:SPEed?", b"1\n")], "2x"),
99 ),
100 )
101 def test_sweep_speed_getter(comm_pairs, value):
102 with expected_protocol(
103 AQ6370D,
104 comm_pairs,
105 ) as inst:
106 assert inst.sweep_speed == value
107
108
109 def test_wavelength_center_getter():
110 with expected_protocol(
111 AQ6370D,
112 [(b":SENSe:WAVelength:CENTer?", b"+8.50000000E-007\n")],
113 ) as inst:
114 assert inst.wavelength_center == 8.5e-07
115
116
117 def test_wavelength_span_setter():
118 with expected_protocol(
119 AQ6370D,
120 [(b":SENSe:WAVelength:SPAN 1e-08", None)],
121 ) as inst:
122 inst.wavelength_span = 1e-08
123
124
125 def test_wavelength_span_getter():
126 with expected_protocol(
127 AQ6370D,
128 [(b":SENSe:WAVelength:SPAN?", b"+1.00000000E-007\n")],
129 ) as inst:
130 assert inst.wavelength_span == 1e-07
131
132
133 def test_wavelength_start_setter():
134 with expected_protocol(
135 AQ6370D,
136 [(b":SENSe:WAVelength:STARt 8e-07", None)],
137 ) as inst:
138 inst.wavelength_start = 8e-07
139
140
141 def test_wavelength_stop_setter():
142 with expected_protocol(
143 AQ6370D,
144 [(b":SENSe:WAVelength:STOP 9e-07", None)],
145 ) as inst:
146 inst.wavelength_stop = 9e-07
147
148
149 def test_delete_trace():
150 with expected_protocol(
151 AQ6370D,
152 [(b":TRACe:DELete TRA", None)],
153 ) as inst:
154 assert (
155 inst.delete_trace(
156 *("A",),
157 )
158 is None
159 )
160
161
162 def test_execute_analysis():
163 with expected_protocol(
164 AQ6370D,
165 [(b":CALCulate", None)],
166 ) as inst:
167 assert inst.execute_analysis() is None
168
169
170 def test_get_analysis():
171 with expected_protocol(
172 AQ6370D,
173 [(b":CALCulate:DATA?", None)],
174 ) as inst:
175 assert inst.get_analysis() is None
176
177
178 def test_get_xdata():
179 with expected_protocol(
180 AQ6370D,
181 [
182 (
183 b":TRACe:X? TRA",
184 b"""+8.45000000E-007,+8.45100000E-007,+8.45200000E-007,+8.45300000E-007,
185 +8.45400000E-007,+8.45500000E-007,+8.45600000E-007,+8.45700000E-007,
186 +8.45800000E-007,+8.45900000E-007,+8.46000000E-007,+8.46100000E-007,
187 +8.46200000E-007,+8.46300000E-007,+8.46400000E-007,+8.46500000E-007,
188 +8.46600000E-007,+8.46700000E-007,+8.46800000E-007,+8.46900000E-007,
189 +8.47000000E-007,+8.47100000E-007,+8.47200000E-007,+8.47300000E-007,
190 +8.47400000E-007,+8.47500000E-007,+8.47600000E-007,+8.47700000E-007,
191 +8.47800000E-007,+8.47900000E-007,+8.48000000E-007,+8.48100000E-007,
192 +8.48200000E-007,+8.48300000E-007,+8.48400000E-007,+8.48500000E-007,
193 +8.48600000E-007,+8.48700000E-007,+8.48800000E-007,+8.48900000E-007,
194 +8.49000000E-007,+8.49100000E-007,+8.49200000E-007,+8.49300000E-007,
195 +8.49400000E-007,+8.49500000E-007,+8.49600000E-007,+8.49700000E-007,
196 +8.49800000E-007,+8.49900000E-007,+8.50000000E-007,+8.50100000E-007,
197 +8.50200000E-007,+8.50300000E-007,+8.50400000E-007,+8.50500000E-007,
198 +8.50600000E-007,+8.50700000E-007,+8.50800000E-007,+8.50900000E-007,
199 +8.51000000E-007,+8.51100000E-007,+8.51200000E-007,+8.51300000E-007,
200 +8.51400000E-007,+8.51500000E-007,+8.51600000E-007,+8.51700000E-007,
201 +8.51800000E-007,+8.51900000E-007,+8.52000000E-007,+8.52100000E-007,
202 +8.52200000E-007,+8.52300000E-007,+8.52400000E-007,+8.52500000E-007,
203 +8.52600000E-007,+8.52700000E-007,+8.52800000E-007,+8.52900000E-007,
204 +8.53000000E-007,+8.53100000E-007,+8.53200000E-007,+8.53300000E-007,
205 +8.53400000E-007,+8.53500000E-007,+8.53600000E-007,+8.53700000E-007,
206 +8.53800000E-007,+8.53900000E-007,+8.54000000E-007,+8.54100000E-007,
207 +8.54200000E-007,+8.54300000E-007,+8.54400000E-007,+8.54500000E-007,
208 +8.54600000E-007,+8.54700000E-007,+8.54800000E-007,+8.54900000E-007,
209 +8.55000000E-007\n""",
210 )
211 ],
212 ) as inst:
213 assert inst.get_xdata(
214 *("TRA",),
215 ) == [
216 8.45e-07,
217 8.451e-07,
218 8.452e-07,
219 8.453e-07,
220 8.454e-07,
221 8.455e-07,
222 8.456e-07,
223 8.457e-07,
224 8.458e-07,
225 8.459e-07,
226 8.46e-07,
227 8.461e-07,
228 8.462e-07,
229 8.463e-07,
230 8.464e-07,
231 8.465e-07,
232 8.466e-07,
233 8.467e-07,
234 8.468e-07,
235 8.469e-07,
236 8.47e-07,
237 8.471e-07,
238 8.472e-07,
239 8.473e-07,
240 8.474e-07,
241 8.475e-07,
242 8.476e-07,
243 8.477e-07,
244 8.478e-07,
245 8.479e-07,
246 8.48e-07,
247 8.481e-07,
248 8.482e-07,
249 8.483e-07,
250 8.484e-07,
251 8.485e-07,
252 8.486e-07,
253 8.487e-07,
254 8.488e-07,
255 8.489e-07,
256 8.49e-07,
257 8.491e-07,
258 8.492e-07,
259 8.493e-07,
260 8.494e-07,
261 8.495e-07,
262 8.496e-07,
263 8.497e-07,
264 8.498e-07,
265 8.499e-07,
266 8.5e-07,
267 8.501e-07,
268 8.502e-07,
269 8.503e-07,
270 8.504e-07,
271 8.505e-07,
272 8.506e-07,
273 8.507e-07,
274 8.508e-07,
275 8.509e-07,
276 8.51e-07,
277 8.511e-07,
278 8.512e-07,
279 8.513e-07,
280 8.514e-07,
281 8.515e-07,
282 8.516e-07,
283 8.517e-07,
284 8.518e-07,
285 8.519e-07,
286 8.52e-07,
287 8.521e-07,
288 8.522e-07,
289 8.523e-07,
290 8.524e-07,
291 8.525e-07,
292 8.526e-07,
293 8.527e-07,
294 8.528e-07,
295 8.529e-07,
296 8.53e-07,
297 8.531e-07,
298 8.532e-07,
299 8.533e-07,
300 8.534e-07,
301 8.535e-07,
302 8.536e-07,
303 8.537e-07,
304 8.538e-07,
305 8.539e-07,
306 8.54e-07,
307 8.541e-07,
308 8.542e-07,
309 8.543e-07,
310 8.544e-07,
311 8.545e-07,
312 8.546e-07,
313 8.547e-07,
314 8.548e-07,
315 8.549e-07,
316 8.55e-07,
317 ]
318
319
320 def test_get_ydata():
321 with expected_protocol(
322 AQ6370D,
323 [
324 (
325 b":TRACe:Y? TRA",
326 b"""-5.80586383E+001,-4.82452558E+001,-2.10000000E+002,-5.00581515E+001,
327 -2.10000000E+002,-2.10000000E+002,-2.10000000E+002,-5.39718179E+001,
328 -2.10000000E+002,-4.83172555E+001,-2.10000000E+002,-5.40078179E+001,
329 -9.28245811E+001,-4.71722994E+001,-2.10000000E+002,-5.20649217E+001,
330 -2.10000000E+002,-2.10000000E+002,-4.58900745E+001,-4.76780332E+001,
331 -4.88929655E+001,-4.59160745E+001,-5.89591856E+001,-6.04801307E+001,
332 -4.56972546E+001,-5.37341531E+001,-4.68775174E+001,-4.63697811E+001,
333 -2.10000000E+002,-4.58639117E+001,-2.10000000E+002,-5.04835809E+001,
334 -2.10000000E+002,-4.55457108E+001,-2.10000000E+002,-2.10000000E+002,
335 -5.25281289E+001,-5.25381299E+001,-6.83873225E+001,-4.97480469E+001,
336 -5.03931511E+001,-4.94802372E+001,-4.99253305E+001,-5.57736026E+001,
337 -4.43726648E+001,-2.10000000E+002,-2.10000000E+002,-2.10000000E+002,
338 -2.10000000E+002,-5.35840271E+001,-2.10000000E+002,-2.10000000E+002,
339 -4.61320419E+001,-2.10000000E+002,-4.82889238E+001,-4.89605452E+001,
340 -4.80090332E+001,-2.10000000E+002,-5.24489220E+001,-5.59126029E+001,
341 -4.93780799E+001,-2.10000000E+002,-5.22268893E+001,-4.99580469E+001,
342 -2.10000000E+002,-5.37240266E+001,-6.86322957E+001,-2.10000000E+002,
343 -2.10000000E+002,-2.10000000E+002,-4.70394921E+001,-4.96060890E+001,
344 -2.10000000E+002,-4.75372963E+001,-2.10000000E+002,-2.10000000E+002,
345 -2.10000000E+002,-2.10000000E+002,-5.42071536E+001,-4.70477584E+001,
346 -2.10000000E+002,-2.10000000E+002,-2.10000000E+002,-2.10000000E+002,
347 -5.67689941E+001,-4.81764150E+001,-2.10000000E+002,-4.87957619E+001,
348 -2.10000000E+002,-2.10000000E+002,-5.51568122E+001,-2.10000000E+002,
349 -5.09619656E+001,-2.10000000E+002,-5.43551546E+001,-4.71242549E+001,
350 -5.27949223E+001,-5.43831531E+001,-2.10000000E+002,-4.94815222E+001,
351 -6.89463024E+001\n""",
352 )
353 ],
354 ) as inst:
355 assert inst.get_ydata(
356 *("TRA",),
357 ) == [
358 -58.0586383,
359 -48.2452558,
360 -210.0,
361 -50.0581515,
362 -210.0,
363 -210.0,
364 -210.0,
365 -53.9718179,
366 -210.0,
367 -48.3172555,
368 -210.0,
369 -54.0078179,
370 -92.8245811,
371 -47.1722994,
372 -210.0,
373 -52.0649217,
374 -210.0,
375 -210.0,
376 -45.8900745,
377 -47.6780332,
378 -48.8929655,
379 -45.9160745,
380 -58.9591856,
381 -60.4801307,
382 -45.6972546,
383 -53.7341531,
384 -46.8775174,
385 -46.3697811,
386 -210.0,
387 -45.8639117,
388 -210.0,
389 -50.4835809,
390 -210.0,
391 -45.5457108,
392 -210.0,
393 -210.0,
394 -52.5281289,
395 -52.5381299,
396 -68.3873225,
397 -49.7480469,
398 -50.3931511,
399 -49.4802372,
400 -49.9253305,
401 -55.7736026,
402 -44.3726648,
403 -210.0,
404 -210.0,
405 -210.0,
406 -210.0,
407 -53.5840271,
408 -210.0,
409 -210.0,
410 -46.1320419,
411 -210.0,
412 -48.2889238,
413 -48.9605452,
414 -48.0090332,
415 -210.0,
416 -52.448922,
417 -55.9126029,
418 -49.3780799,
419 -210.0,
420 -52.2268893,
421 -49.9580469,
422 -210.0,
423 -53.7240266,
424 -68.6322957,
425 -210.0,
426 -210.0,
427 -210.0,
428 -47.0394921,
429 -49.606089,
430 -210.0,
431 -47.5372963,
432 -210.0,
433 -210.0,
434 -210.0,
435 -210.0,
436 -54.2071536,
437 -47.0477584,
438 -210.0,
439 -210.0,
440 -210.0,
441 -210.0,
442 -56.7689941,
443 -48.176415,
444 -210.0,
445 -48.7957619,
446 -210.0,
447 -210.0,
448 -55.1568122,
449 -210.0,
450 -50.9619656,
451 -210.0,
452 -54.3551546,
453 -47.1242549,
454 -52.7949223,
455 -54.3831531,
456 -210.0,
457 -49.4815222,
458 -68.9463024,
459 ]
460
461
462 def test_initiate_sweep():
463 with expected_protocol(
464 AQ6370D,
465 [(b":INITiate:IMMediate", None)],
466 ) as inst:
467 assert inst.initiate_sweep() is None
468
469
470 def test_reset():
471 with expected_protocol(
472 AQ6370D,
473 [(b"*RST", None)],
474 ) as inst:
475 assert inst.reset() is None
476
477
478 def test_set_level_position_to_max():
479 with expected_protocol(
480 AQ6370D,
481 [(b":CALCulate:MARKer:MAXimum:SRLevel", None)],
482 ) as inst:
483 assert inst.set_level_position_to_max() is None