def test_skip_empty(task): """Test skipping an empty value. """ task.feval = '2*{Loop_val}' val, res, msg = validators.SkipEmpty().check(task, 'feval') assert val == 2 assert res assert not msg task.feval = '' val, res, msg = validators.SkipEmpty().check(task, 'feval') assert val is None assert res assert not msg
from exopy.tasks.api import (InstrumentTask, validators) from atom.api import Float, Unicode, Long from qm.qua import * import numbers EMPTY_REAL = validators.SkipEmpty(types=numbers.Real) EMPTY_INT = validators.SkipEmpty(types=numbers.Integral) class SetMixerCorrectionTask(InstrumentTask): """ Sets the mixer's correction matrix """ mixer = Unicode().tag(pref=True) intermediate_frequency = Unicode().tag(pref=True, feval=EMPTY_INT) lo_frequency = Unicode().tag(pref=True, feval=EMPTY_INT) v00 = Unicode().tag(pref=True, feval=EMPTY_REAL) v01 = Unicode().tag(pref=True, feval=EMPTY_REAL) v10 = Unicode().tag(pref=True, feval=EMPTY_REAL) v11 = Unicode().tag(pref=True, feval=EMPTY_REAL) def __init__(self, **kwargs): super().__init__(**kwargs) def perform(self): v00 = self.format_and_eval_string(self.v00) v01 = self.format_and_eval_string(self.v01) v10 = self.format_and_eval_string(self.v10) v11 = self.format_and_eval_string(self.v11) intermediate_frequency = self.format_and_eval_string(self.intermediate_frequency)
channel_driver = Value() def check(self, *args, **kwargs): """ Add checking for channels to the base tests. """ test, traceback = super(SingleChannelPNATask, self).check(*args, **kwargs) c_test, c_trace = check_channels_presence(self, [self.channel], *args, **kwargs) traceback.update(c_trace) return test and c_test, traceback FEVAL = validators.SkipEmpty(types=numbers.Real) class ENASweepTask(SingleChannelPNATask): """Measure the specified parameters while sweeping either the frequency or the power. Measure are saved in an array with named fields : Frequency or Power and then 'Measure'_'Format' (S21_MLIN, S33 if Raw) Wait for any parallel operation before execution. """ channel = Int(1).tag(pref=True) start = Str().tag(pref=True, feval=FEVAL) stop = Str().tag(pref=True, feval=FEVAL)