当前位置: 首页>>代码示例>>Python>>正文


Python api.RootTask类代码示例

本文整理汇总了Python中hqc_meas.tasks.api.RootTask的典型用法代码示例。如果您正苦于以下问题:Python RootTask类的具体用法?Python RootTask怎么用?Python RootTask使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RootTask类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setup

 def setup(self):
     root = RootTask()
     root.should_pause = Event()
     root.should_stop = Event()
     root.paused = Event()
     root.default_path = "toto"
     self.root = root
开发者ID:PhilipVinc,项目名称:HQCMeas,代码行数:7,代码来源:test_execution.py

示例2: test_child_deletion_handling1

def test_child_deletion_handling1():
    # Test that adding a task to the root task is correctly handled.
    root = RootTask()
    task1 = ComplexTask(task_name='task1',
                        task_database_entries={'val1': 2.0})
    root.children_task.append(task1)

    root.children_task = []
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:8,代码来源:test_base_tasks.py

示例3: test_build_from_config1

 def test_build_from_config1(self):
     # Test building a interfaceable task from a config.
     aux = RootTask()
     aux.children_task = [IMixin()]
     bis = RootTask.build_from_config(aux.task_preferences,
                                      {'tasks': {'IMixin': IMixin,
                                                 'RootTask': RootTask}})
     assert_equal(type(bis.children_task[0]).__name__, 'IMixin')
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:8,代码来源:test_task_interfaces.py

示例4: test_ex_access_handling1

def test_ex_access_handling1():
    # Test adding an ex_access for an entry.
    root = RootTask()
    task1 = ComplexTask(task_name='task1')
    root.children_task.append(task1)
    task2 = SimpleTask(task_name='task2',
                       task_database_entries={'val2': 'r'})
    task1.children_task.append(task2)

    assert_raises(KeyError, root.get_from_database, 'task2_val2')
    task1.add_access_exception('task2_val2')
    assert_equal(root.get_from_database('task2_val2'), 'r')
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:12,代码来源:test_base_tasks.py

示例5: test_child_addition_handling1

def test_child_addition_handling1():
    # Test that adding a task to the root task is correctly handled.
    root = RootTask()
    task1 = ComplexTask(task_name='task1',
                        task_database_entries={'val1': 2.0})
    root.children_task.append(task1)

    assert_equal(task1.task_depth, 1)
    assert_equal(task1.task_path, 'root')
    assert_is(task1.task_database, root.task_database)
    assert_is(task1.root_task, root)
    assert_is(task1.parent_task, root)

    assert_equal(task1.get_from_database('task1_val1'), 2.0)
    assert_equal(root.get_from_database('task1_val1'), 2.0)
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:15,代码来源:test_base_tasks.py

示例6: build_task_from_config

def build_task_from_config(config, dep_source, root=False):
    """ Rebuild a task hierarchy from a Section.

    Parameters
    ----------
    config : Section
        Section representing the task hierarchy.

    dep_source :
        Source of the build dependencies of the hierarchy. This can either
        be the instance of the TaskManager of a dict of dependencies.

    Returns
    -------
    task :
        Newly built task.

    """
    if not isinstance(dep_source, dict):
        core = dep_source.workbench.get_plugin('enaml.workbench.core')
        cmd = 'hqc_meas.dependencies.collect_build_dep_from_config'
        dep_source = core.invoke_command(cmd, {'config': config})
        if isinstance(dep_source, Exception):
            return None

    if root:
        return RootTask.build_from_config(config, dep_source)
    else:
        task_class = dep_source['tasks'][config.pop('task_class')]
        return task_class.build_from_config(config, dep_source)
开发者ID:PhilipVinc,项目名称:HQCMeas,代码行数:30,代码来源:building.py

示例7: TestLogTask

class TestLogTask(object):

    def setup(self):
        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = LogTask(task_name='Test')
        self.root.children_task.append(self.task)

    def test_check1(self):
        # Simply test that everything is ok message is evaluable.
        self.task.message = 'True'

        test, traceback = self.task.check()
        assert_true(test)
        assert_false(traceback)

    def test_check2(self):
        # Test handling a wrong message.
        self.task.message = 'True{'

        test, traceback = self.task.check()
        assert_false(test)
        assert_equal(len(traceback), 1)
        assert_in('root/Test', traceback)

    def test_perform(self):
        # Test performing when condition is True.
        self.task.message = 'toro'

        self.root.task_database.prepare_for_running()

        self.task.perform()
        assert_equal(self.root.get_from_database('Test_message'), 'toro')
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:32,代码来源:test_log_task.py

示例8: setup

    def setup(self):
        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = TransferPulseSequenceTask(task_name='Test')
        self.root.children_task.append(self.task)
        self.root.run_time['drivers'] = {'AWG5014B': InstrHelper}
        self.root.write_in_database('int', 2)

        self.sequence = RootSequence()
        self.context = AWGContext()
        self.sequence.context = self.context
        self.sequence.external_vars = {'a': None}
        pulse1 = Pulse(def_1='1.0', def_2='{a}', channel='Ch1_M1')
        pulse2 = Pulse(def_1='{a} + 1.0', def_2='4.0', channel='Ch1_M1')
        pulse3 = Pulse(def_1='{2_stop} + 0.5', def_2='10', channel='Ch1_M1')
        self.sequence.items.extend([pulse1, pulse2, pulse3])

        self.task.sequence = self.sequence
        self.task.sequence_vars = {'a': '{Root_int}'}

        interface = AWGTransferInterface(task=self.task)
        self.task.interface = interface

        self.task.selected_driver = 'AWG5014B'
        self.task.selected_profile = 'Test1'

        def get_ch(s, ch):
            return InstrHelper(({'output_state': 'OFF'},
                                {'select_sequence': lambda s, se: None}))
        prof = ({'owner': [None], 'defined_channels': ('Ch1',)},
                {'get_channel': get_ch, 'to_send': lambda s, se: None})
        self.root.run_time['profiles'] = {'Test1': prof}
开发者ID:PhilipVinc,项目名称:HQCMeas,代码行数:31,代码来源:test_transfer_pulse_sequence_task.py

示例9: setup

    def setup(self):
        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = SaveFileTask(task_name='Test')
        self.root.children_task.append(self.task)

        self.root.write_in_database('int', 1)
        self.root.write_in_database('float', 2.0)
        self.root.write_in_database('array', np.array(range(10)))
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:8,代码来源:test_save_tasks.py

示例10: setup

 def setup(self):
     self.root = RootTask(should_stop=Event(), should_pause=Event())
     self.task = ArrayExtremaTask(task_name='Test')
     self.root.children_task.append(self.task)
     array = np.zeros((5,), dtype=[('var1', 'f8'), ('var2', 'f8')])
     array['var1'][1] = -1
     array['var1'][3] = 1
     self.root.write_in_database('array', array)
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:8,代码来源:test_array_tasks.py

示例11: setup

    def setup(self):
        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = SaveTask(task_name='Test')
        self.root.children_task.append(self.task)

        self.root.write_in_database('int', 1)
        self.root.write_in_database('float', 2.0)
        self.root.write_in_database('str', 'a')
开发者ID:jf---,项目名称:HQCMeas,代码行数:8,代码来源:test_save_tasks.py

示例12: setup

    def setup(self):
        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = ApplyMagFieldTask(task_name='Test')
        self.root.children_task.append(self.task)
        self.root.run_time['drivers'] = {'Test': InstrHelper}

        # This is set simply to make sure the test of InstrTask pass.
        self.task.selected_driver = 'Test'
        self.task.selected_profile = 'Test1'
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:9,代码来源:test_apply_mag_field_task.py

示例13: test_collect_dependencies

    def test_collect_dependencies(self):
        # Test collecting build dependencies.
        self.workbench.register(TaskManagerManifest())
        from hqc_meas.tasks.api import RootTask, ComplexTask
        from hqc_meas.tasks.tasks_util.log_task import LogTask

        aux = [LogTask(task_name="r")]
        root = RootTask(task_name="root")
        root.children_task = [ComplexTask(task_name="complex", children_task=aux), LogTask(task_name="t")]

        core = self.workbench.get_plugin(u"enaml.workbench.core")
        com = u"hqc_meas.dependencies.collect_dependencies"
        res, build, run = core.invoke_command(com, {"obj": root}, core)
        assert_true(res)
        assert_in("tasks", build)
        assert_equal(sorted(["LogTask", "ComplexTask"]), sorted(build["tasks"].keys()))
        assert_not_in("interfaces", build)
        assert_false(run)
开发者ID:PhilipVinc,项目名称:HQCMeas,代码行数:18,代码来源:test_plugin.py

示例14: test_ex_access_handling5

def test_ex_access_handling5():
    # Test removing a task with whose one entry has an ex_access, and then
    # adding a different task (same name, same class, etc)
    root = RootTask()
    task1 = ComplexTask(task_name='task1')
    root.children_task.append(task1)
    task2 = SimpleTask(task_name='task2',
                       task_database_entries={'val2': 'r'})
    task1.children_task.append(task2)

    task1.add_access_exception('task2_val2')
    assert_equal(root.get_from_database('task2_val2'), 'r')
    task1.children_task = []
    assert_raises(KeyError, root.get_from_database, 'task2_val2')
    task3 = SimpleTask(task_name='task2',
                       task_database_entries={'val2': 'r'})
    task1.children_task.append(task3)
    assert_raises(KeyError, root.get_from_database, 'task2_val2')
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:18,代码来源:test_base_tasks.py

示例15: TestPNASetRFFrequencyTask

class TestPNASetRFFrequencyTask(object):

    def setup(self):
        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = SetRFFrequencyTask(task_name='Test')
        self.root.children_task.append(self.task)
        self.root.run_time['drivers'] = {'Test': InstrHelper}

        self.task.unit = 'GHz'

        # This is set simply to make sure the test of InstrTask pass.
        self.task.selected_driver = 'Test'
        self.task.selected_profile = 'Test1'

    def test_check_pna_interface1(self):
        # Simply test that everything is ok if frequency can be evaluated.
        self.task.interface = PNASetRFFrequencyInterface(task=self.task,
                                                         channel=1)
        self.task.frequency = '1.0'

        profile = {'Test1': ({'defined_channels': [[1]]},
                             {})}
        self.root.run_time['profiles'] = profile

        test, traceback = self.task.check(test_instr=True)
        assert_true(test)
        assert_false(traceback)

    def test_check_pna_interface2(self):
        # Check handling a wrong channel.
        self.task.interface = PNASetRFFrequencyInterface(task=self.task,
                                                         channel=1)
        self.task.frequency = '1.0'

        profile = {'Test1': ({'defined_channels': [[2]]},
                             {})}
        self.root.run_time['profiles'] = profile

        test, traceback = self.task.check(test_instr=True)
        assert_false(test)
        assert_equal(len(traceback), 1)

    def test_perform_pna_interface(self):
        self.task.interface = PNASetRFFrequencyInterface(task=self.task)
        self.task.frequency = '1.0'

        profile = {'Test1': ({'frequency': [0.0],
                              'owner': [None]},
                             {'get_channel': lambda x, i: x}
                             )}
        self.root.run_time['profiles'] = profile

        self.root.task_database.prepare_for_running()

        self.task.perform()
        assert_equal(self.root.get_from_database('Test_frequency'), 1.0e9)
开发者ID:MatthieuDartiailh,项目名称:HQCMeas,代码行数:56,代码来源:test_pna_tasks.py


注:本文中的hqc_meas.tasks.api.RootTask类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。