def test_get_accessible_vars():
    """Test getting the accessible vars of a sequence.

    """
    root = RootSequence(external_vars=OrderedDict({'a': 1}),
                        local_vars=OrderedDict({'a2': '5'}),
                        time_constrained=True)
    context = TestContext()
    root.context = context
    sequence1 = BaseSequence(local_vars=OrderedDict({'b': '1'}))
    sequence2 = BaseSequence(local_vars=OrderedDict({'c': '2'}))
    pulse = Pulse()

    sequence2.add_child_item(0, pulse)
    sequence1.add_child_item(0, sequence2)
    root.add_child_item(0, sequence1)

    variables = [
        'sequence_end', 'a', 'a2', '3_start', '3_stop', '3_duration', 'b', 'c'
    ]
    lv = sequence2.get_accessible_vars()
    for v in variables:
        assert v in lv

    variables.pop()
    lv = sequence1.get_accessible_vars()
    for v in variables:
        assert v in lv

    variables.pop()
    lv = root.get_accessible_vars()
    for v in variables:
        assert v in lv
def test_build_from_config2(template_sequence, template_dependencies):
    """ Test rebuilding a sequence including a template sequence.

    Channel mapping of template_vars values are known.

    """
    conf = {'template_id': 'test', 'name': 'Template',
            'template_vars': "{'b': '25'}"}
    seq = TemplateSequence.build_from_config(conf, template_dependencies)
    seq.context.channel_mapping = {'A': 'Ch1_L', 'B': 'Ch2_L',
                                   'Ch1': 'Ch2_A', 'Ch2': 'Ch1_A'}
    root = RootSequence()
    context = TestContext(sampling=0.5)
    root.context = context
    root.add_child_item(0, seq)
    pref = root.preferences_from_members()

    new = RootSequence.build_from_config(pref, template_dependencies)
    assert new.items[0].index == 1

    seq = new.items[0]
    assert seq.name == 'Template'
    assert seq.template_id == template_sequence
    assert seq.template_vars == dict(b='25')
    assert seq.local_vars == dict(a='1.5')
    assert len(seq.items) == 4
    assert seq.items[3].index == 5
    assert seq.docs == 'Basic user comment\nff'

    context = seq.context
    assert context.template is seq
    assert context.logical_channels == ['A', 'B']
    assert context.analogical_channels == ['Ch1', 'Ch2']
    assert context.channel_mapping == {'A': 'Ch1_L', 'B': 'Ch2_L',
                                       'Ch1': 'Ch2_A', 'Ch2': 'Ch1_A'}
Example #3
0
def test_get_accessible_vars():
    """Test getting the accessible vars of a sequence.

    """
    root = RootSequence(external_vars={'a': 1}, local_vars={'a2': '5'},
                        time_constrained=True)
    context = TestContext()
    root.context = context
    sequence1 = BaseSequence(local_vars={'b': '1'})
    sequence2 = BaseSequence(local_vars={'c': '2'})
    pulse = Pulse()

    sequence2.add_child_item(0, pulse)
    sequence1.add_child_item(0, sequence2)
    root.add_child_item(0, sequence1)

    variables = ['sequence_end', 'a', 'a2', '3_start', '3_stop',
                 '3_duration', 'b', 'c']
    lv = sequence2.get_accessible_vars()
    for v in variables:
        assert v in lv

    variables.pop()
    lv = sequence1.get_accessible_vars()
    for v in variables:
        assert v in lv

    variables.pop()
    lv = root.get_accessible_vars()
    for v in variables:
        assert v in lv
Example #4
0
def template_sequence(pulses_plugin):
    """Create a template sequence and make sure the plugin pick it up.

    """
    from ecpy_pulses.pulses.pulse import Pulse
    from ecpy_pulses.pulses.sequences.base_sequences import (RootSequence,
                                                             BaseSequence)
    from ecpy_pulses.pulses.shapes.square_shape import SquareShape
    from ecpy_pulses.pulses.contexts.template_context import TemplateContext

    root = RootSequence()
    context = TemplateContext(logical_channels=['A', 'B'],
                              analogical_channels=['Ch1', 'Ch2'],
                              channel_mapping={
                                  'A': '',
                                  'B': '',
                                  'Ch1': '',
                                  'Ch2': ''
                              })
    root.context = context
    root.local_vars = OrderedDict({'a': '1.5'})

    pulse1 = Pulse(channel='A', def_1='1.0', def_2='{a}')
    pulse2 = Pulse(channel='B', def_1='{a} + 1.0', def_2='3.0')
    pulse3 = Pulse(channel='Ch1',
                   def_1='{2_stop} + 0.5',
                   def_2='{b}',
                   kind='Analogical',
                   shape=SquareShape())
    seq = BaseSequence()
    seq.add_child_item(
        0,
        Pulse(channel='Ch2',
              def_1='{2_stop} + 0.5',
              def_2='{sequence_end}',
              kind='Analogical',
              shape=SquareShape()))
    for i in [pulse1, pulse2, seq, pulse3][::-1]:
        root.add_child_item(0, i)

    pref = root.preferences_from_members()
    pref['template_vars'] = repr(dict(b=''))
    del pref['item_id']
    del pref['external_vars']
    del pref['time_constrained']

    temp_path = os.path.join(pulses_plugin.templates_folders[0],
                             '__dummy__.temp_pulse.ini')
    save_sequence_prefs(temp_path, pref, 'dummy doc')

    pulses_plugin._refresh_known_template_sequences()

    return '__dummy__'
def test_build_from_config2(template_sequence, template_dependencies):
    """ Test rebuilding a sequence including a template sequence.

    Channel mapping of template_vars values are known.

    """
    conf = {
        'template_id': 'test',
        'name': 'Template',
        'template_vars': "{'b': '25'}"
    }
    seq = TemplateSequence.build_from_config(conf, template_dependencies)
    seq.context.channel_mapping = {
        'A': 'Ch1_L',
        'B': 'Ch2_L',
        'Ch1': 'Ch2_A',
        'Ch2': 'Ch1_A'
    }
    root = RootSequence()
    context = TestContext(sampling=0.5)
    root.context = context
    root.add_child_item(0, seq)
    pref = root.preferences_from_members()

    new = RootSequence.build_from_config(pref, template_dependencies)
    assert new.items[0].index == 1

    seq = new.items[0]
    assert seq.name == 'Template'
    assert seq.template_id == template_sequence
    assert seq.template_vars == dict(b='25')
    assert seq.local_vars == dict(a='1.5')
    assert len(seq.items) == 4
    assert seq.items[3].index == 5
    assert seq.docs == 'Basic user comment\nff'

    context = seq.context
    assert context.template is seq
    assert context.logical_channels == ['A', 'B']
    assert context.analogical_channels == ['Ch1', 'Ch2']
    assert context.channel_mapping == {
        'A': 'Ch1_L',
        'B': 'Ch2_L',
        'Ch1': 'Ch2_A',
        'Ch2': 'Ch1_A'
    }
def root_with_template(template_sequence, template_dependencies):
    """Build a root using the template sequence.

    """
    root = RootSequence()
    root.context = TestContext(sampling=0.5)

    conf = {'template_id': template_sequence, 'name': 'Template',
            'template_vars': "{'b': '19'}"}
    seq = TemplateSequence.build_from_config(conf, template_dependencies)
    seq.context.channel_mapping = {'A': 'Ch1_L', 'B': 'Ch2_L',
                                   'Ch1': 'Ch2_A', 'Ch2': 'Ch1_A'}
    seq.def_1 = '1.0'
    seq.def_2 = '20.0'

    root.add_child_item(0, seq)
    return root
def sequence():
    """Create a sequence.

    """
    root = RootSequence()
    context = TestContext(sampling=0.5)
    root.context = context

    root.external_vars = {"a": 1.5}
    root.local_vars = {"b": "2*{a}"}

    pulse1 = Pulse(def_1="1.0", def_2="{a}")
    pulse2 = Pulse(def_1="{a} + 1.0", def_2="3.0")
    pulse3 = Pulse(def_1="{2_stop} + 0.5", def_2="10 + {b}")
    for i, c in enumerate((pulse1, pulse2, pulse3)):
        root.add_child_item(i, c)

    return root
Example #8
0
def sequence():
    """Create a sequence.

    """
    root = RootSequence()
    context = TestContext(sampling=0.5)
    root.context = context

    root.external_vars = OrderedDict({'a': None})
    root.local_vars = OrderedDict({'b': '2*{a}'})

    pulse1 = Pulse(def_1='1.0', def_2='{a}', def_mode=str('Start/Stop'))
    pulse2 = Pulse(def_1='{a} + 1.0', def_2='3.0')
    pulse3 = Pulse(def_1='{2_stop} + 0.5', def_2='10 + {b}')
    for i, c in enumerate((pulse1, pulse2, pulse3)):
        root.add_child_item(i, c)

    return root
Example #9
0
def test_root_handling():
    """Test updating of item when a sequence get/lose the root.

    """
    root = RootSequence()
    context = TestContext()
    root.context = context
    sequence1 = BaseSequence()
    sequence2 = BaseSequence()
    pulse = Pulse()

    sequence2.add_child_item(0, pulse)
    sequence1.add_child_item(0, sequence2)
    root.add_child_item(0, sequence1)

    assert pulse.root is root and sequence2.root is root
    assert sequence2.has_observers('_last_index')

    root.remove_child_item(0)
    assert pulse.root is None and sequence2.root is None
    assert not sequence2.has_observers('_last_index')
def test_root_handling():
    """Test updating of item when a sequence get/lose the root.

    """
    root = RootSequence()
    context = TestContext()
    root.context = context
    sequence1 = BaseSequence()
    sequence2 = BaseSequence()
    pulse = Pulse()

    sequence2.add_child_item(0, pulse)
    sequence1.add_child_item(0, sequence2)
    root.add_child_item(0, sequence1)

    assert pulse.root is root and sequence2.root is root
    assert sequence2.has_observers('_last_index')

    root.remove_child_item(0)
    assert pulse.root is None and sequence2.root is None
    assert not sequence2.has_observers('_last_index')
Example #11
0
def template_sequence(pulses_plugin):
    """Create a template sequence and make sure the plugin pick it up.

    """
    from ecpy_pulses.pulses.pulse import Pulse
    from ecpy_pulses.pulses.sequences.base_sequences import RootSequence, BaseSequence
    from ecpy_pulses.pulses.shapes.square_shape import SquareShape
    from ecpy_pulses.pulses.contexts.template_context import TemplateContext

    root = RootSequence()
    context = TemplateContext(
        logical_channels=["A", "B"],
        analogical_channels=["Ch1", "Ch2"],
        channel_mapping={"A": "", "B": "", "Ch1": "", "Ch2": ""},
    )
    root.context = context
    root.local_vars = {"a": "1.5"}

    pulse1 = Pulse(channel="A", def_1="1.0", def_2="{a}")
    pulse2 = Pulse(channel="B", def_1="{a} + 1.0", def_2="3.0")
    pulse3 = Pulse(channel="Ch1", def_1="{2_stop} + 0.5", def_2="{b}", kind="Analogical", shape=SquareShape())
    seq = BaseSequence()
    seq.add_child_item(
        0, Pulse(channel="Ch2", def_1="{2_stop} + 0.5", def_2="{sequence_end}", kind="Analogical", shape=SquareShape())
    )
    for i in [pulse1, pulse2, seq, pulse3][::-1]:
        root.add_child_item(0, i)

    pref = root.preferences_from_members()
    pref["template_vars"] = repr(dict(b=""))
    del pref["item_id"]
    del pref["external_vars"]
    del pref["time_constrained"]

    temp_path = os.path.join(pulses_plugin.templates_folders[0], "__dummy__.temp_pulse.ini")
    save_sequence_prefs(temp_path, pref, "dummy doc")

    pulses_plugin._refresh_known_template_sequences()

    return "__dummy__"
Example #12
0
def test_sequence_time_constaints_observation():
    """Test observation of time constraint by the root.

    """
    root = RootSequence()
    context = TestContext()
    root.context = context
    sequence = BaseSequence()
    root.add_child_item(0, sequence)

    assert root.global_vars == []

    sequence.time_constrained = True

    assert (sorted(root.global_vars) ==
            sorted(['1_start', '1_stop', '1_duration']))

    sequence.time_constrained = False

    assert root.global_vars == []

    root.time_constrained = True
    assert root.linkable_vars
def test_sequence_time_constaints_observation():
    """Test observation of time constraint by the root.

    """
    root = RootSequence()
    context = TestContext()
    root.context = context
    sequence = BaseSequence()
    root.add_child_item(0, sequence)

    assert root.global_vars == []

    sequence.time_constrained = True

    assert (sorted(root.global_vars) == sorted(
        ['1_start', '1_stop', '1_duration']))

    sequence.time_constrained = False

    assert root.global_vars == []

    root.time_constrained = True
    assert root.linkable_vars
def root_with_template(template_sequence, template_dependencies):
    """Build a root using the template sequence.

    """
    root = RootSequence()
    root.context = TestContext(sampling=0.5)

    conf = {
        'template_id': template_sequence,
        'name': 'Template',
        'template_vars': "{'b': '19'}"
    }
    seq = TemplateSequence.build_from_config(conf, template_dependencies)
    seq.context.channel_mapping = {
        'A': 'Ch1_L',
        'B': 'Ch2_L',
        'Ch1': 'Ch2_A',
        'Ch2': 'Ch1_A'
    }
    seq.def_1 = '1.0'
    seq.def_2 = '20.0'

    root.add_child_item(0, seq)
    return root
def test_collect_dependencies(workbench):
    """Test collecting build dependencies.

    """
    from ecpy_pulses.pulses.sequences.base_sequences import RootSequence
    root = RootSequence(context=TestContext())

    pulse1 = Pulse(def_1='1.0', def_2='{7_start} - 1.0')
    pulse2 = Pulse(def_1='{a} + 1.0', def_2='{6_start} + 1.0')
    pulse3 = Pulse(def_1='{3_stop} + 0.5', def_2='10.0')
    pulse4 = Pulse(def_1='2.0', def_2='0.5', def_mode='Start/Duration')
    pulse5 = Pulse(def_1='{1_stop}', def_2='0.5', def_mode='Start/Duration')
    pulse5.shape = SquareShape(amplitude='0.5')
    pulse5.kind = 'Analogical'

    pulse5.modulation.frequency = '1.0**'
    pulse5.modulation.phase = '1.0'
    pulse5.modulation.activated = True

    sequence2 = BaseSequence()
    sequence2.add_child_item(0, pulse3)
    sequence1 = BaseSequence()
    sequence1.add_child_item(0, pulse2)
    sequence1.add_child_item(1, sequence2)
    sequence1.add_child_item(2, pulse4)

    root.add_child_item(0, pulse1)
    root.add_child_item(1, sequence1)
    root.add_child_item(2, pulse5)

    core = workbench.get_plugin(u'enaml.workbench.core')
    com = 'ecpy.app.dependencies.analyse'
    dep = core.invoke_command(com, {'obj': root, 'dependencies': 'build'})
    assert not dep.errors

    com = 'ecpy.app.dependencies.collect'
    dep = core.invoke_command(com, {
        'kind': 'build',
        'dependencies': dep.dependencies
    })

    assert not dep.errors
    assert 'ecpy.pulses.item' in dep.dependencies
    assert 'ecpy.pulses.context' in dep.dependencies
    assert 'ecpy.pulses.shape' in dep.dependencies
    assert 'ecpy.pulses.modulation' in dep.dependencies
Example #16
0
def test_collect_dependencies(workbench):
    """Test collecting build dependencies.

    """
    from ecpy_pulses.pulses.sequences.base_sequences import RootSequence
    root = RootSequence(context=TestContext())

    pulse1 = Pulse(def_1='1.0', def_2='{7_start} - 1.0')
    pulse2 = Pulse(def_1='{a} + 1.0', def_2='{6_start} + 1.0')
    pulse3 = Pulse(def_1='{3_stop} + 0.5', def_2='10.0')
    pulse4 = Pulse(def_1='2.0', def_2='0.5', def_mode='Start/Duration')
    pulse5 = Pulse(def_1='{1_stop}', def_2='0.5',
                   def_mode='Start/Duration')
    pulse5.shape = SquareShape(amplitude='0.5')
    pulse5.kind = 'Analogical'

    pulse5.modulation.frequency = '1.0**'
    pulse5.modulation.phase = '1.0'
    pulse5.modulation.activated = True

    sequence2 = BaseSequence()
    sequence2.add_child_item(0, pulse3)
    sequence1 = BaseSequence()
    sequence1.add_child_item(0, pulse2)
    sequence1.add_child_item(1, sequence2)
    sequence1.add_child_item(2, pulse4)

    root.add_child_item(0, pulse1)
    root.add_child_item(1, sequence1)
    root.add_child_item(2, pulse5)

    core = workbench.get_plugin(u'enaml.workbench.core')
    com = 'ecpy.app.dependencies.analyse'
    dep = core.invoke_command(com, {'obj': root, 'dependencies': 'build'})
    assert not dep.errors

    com = 'ecpy.app.dependencies.collect'
    dep = core.invoke_command(com, {'kind': 'build',
                                    'dependencies': dep.dependencies})

    assert not dep.errors
    assert 'ecpy.pulses.items' in dep.dependencies
    assert 'ecpy.pulses.contexts' in dep.dependencies
    assert 'ecpy.pulses.shapes' in dep.dependencies
    assert 'ecpy.pulses.modulation' in dep.dependencies
Example #17
0
def test_sequence_indexing2():
    """Test adding, moving, deleting a sequence in a sequence.

    """
    root = RootSequence()
    context = TestContext()
    root.context = context

    pulse1 = Pulse()
    pulse2 = Pulse()
    pulse3 = Pulse()
    pulse4 = Pulse()

    sequence1 = BaseSequence()
    sequence2 = BaseSequence()

    root.add_child_item(0, pulse1)
    root.add_child_item(1, sequence1)
    root.add_child_item(2, pulse2)

    assert sequence1.parent is root
    assert sequence1.root is root

    sequence1.add_child_item(0, sequence2)

    assert sequence2.parent is sequence1
    assert sequence2.root is root
    assert pulse1.index == 1
    assert pulse2.index == 4
    assert (sorted(root.get_accessible_vars()) ==
            sorted(['1_start', '1_stop', '1_duration',
                    '4_start', '4_stop', '4_duration']))

    pulse1.index = 200
    sequence2.add_child_item(0, pulse3)

    assert pulse3.parent is sequence2
    assert pulse3.root is root
    assert pulse2.index == 5
    assert pulse3.index == 4
    assert (sorted(root.get_accessible_vars()) ==
            sorted(['1_start', '1_stop', '1_duration',
                    '4_start', '4_stop', '4_duration',
                    '5_start', '5_stop', '5_duration']))

    # Check that only the pulse below the modified sequence are updated.
    assert pulse1.index == 200
    pulse1.index = 0

    sequence1.add_child_item(0, pulse4)

    assert pulse4.index == 3
    assert sequence2.index == 4
    assert pulse3.index == 5
    assert pulse2.index == 6
    assert (sorted(root.get_accessible_vars()) ==
            sorted(['1_start', '1_stop', '1_duration',
                    '3_start', '3_stop', '3_duration',
                    '5_start', '5_stop', '5_duration',
                    '6_start', '6_stop', '6_duration']))

    sequence1.remove_child_item(1)

    assert sequence2.parent is None
    assert sequence2.index == 0
    assert pulse2.index == 4
    assert (sorted(root.get_accessible_vars()) ==
            sorted(['1_start', '1_stop', '1_duration',
                    '3_start', '3_stop', '3_duration',
                    '4_start', '4_stop', '4_duration']))

    sequence1.index = 200
    root2 = RootSequence()
    sequence2.root = root2
    while True:
        sequence2.remove_child_item(0)
        if not sequence2.items:
            break

    # Check the observer was properly removed
    assert sequence1.index == 200
Example #18
0
def test_sequence_indexing1():
    """Test adding, moving, deleting pulse in a sequence.

    """
    root = RootSequence()
    root.time_constrained = True
    root.sequence_duration = '1.0'
    context = TestContext()
    root.context = context

    pulse1 = Pulse()
    pulse2 = Pulse()
    pulse3 = Pulse()

    root.add_child_item(0, pulse1)
    assert pulse1.index == 1
    assert pulse1.root is root
    assert (sorted(root.get_accessible_vars()) ==
            (sorted(['sequence_end', '1_start', '1_stop', '1_duration'])))

    root.add_child_item(1, pulse2)
    assert pulse1.index == 1
    assert pulse2.index == 2
    assert pulse2.root is root
    assert (sorted(root.get_accessible_vars()) ==
            sorted(['sequence_end', '1_start', '1_stop', '1_duration',
                    '2_start', '2_stop', '2_duration']))

    root.move_child_item(0, 1)
    assert pulse1.index == 2
    assert pulse2.index == 1
    assert (sorted(root.get_accessible_vars()) ==
            sorted(['sequence_end', '1_start', '1_stop', '1_duration',
                    '2_start', '2_stop', '2_duration']))

    root.move_child_item(0, 1)

    root.add_child_item(2, pulse3)
    assert pulse1.index == 1
    assert pulse2.index == 2
    assert pulse3.index == 3
    assert pulse3.root is root
    assert (sorted(root.get_accessible_vars()) ==
            sorted(['sequence_end', '1_start', '1_stop', '1_duration',
                    '2_start', '2_stop', '2_duration',
                    '3_start', '3_stop', '3_duration']))

    root.time_constrained = False
    root.remove_child_item(1)
    assert pulse1.index == 1
    assert pulse2.index == 0
    assert pulse3.index == 2
    assert pulse2.root is None
    assert (sorted(root.get_accessible_vars()) ==
            sorted(['1_start', '1_stop', '1_duration',
                    '2_start', '2_stop', '2_duration']))

    root.add_child_item(1, pulse2)
    assert pulse1.index == 1
    assert pulse2.index == 2
    assert pulse3.index == 3
    assert pulse2.root is root
    assert (sorted(root.get_accessible_vars()) ==
            sorted(['1_start', '1_stop', '1_duration',
                    '2_start', '2_stop', '2_duration',
                    '3_start', '3_stop', '3_duration']))
def test_sequence_indexing2():
    """Test adding, moving, deleting a sequence in a sequence.

    """
    root = RootSequence()
    context = TestContext()
    root.context = context

    pulse1 = Pulse()
    pulse2 = Pulse()
    pulse3 = Pulse()
    pulse4 = Pulse()

    sequence1 = BaseSequence()
    sequence2 = BaseSequence()

    root.add_child_item(0, pulse1)
    root.add_child_item(1, sequence1)
    root.add_child_item(2, pulse2)

    assert sequence1.parent is root
    assert sequence1.root is root

    sequence1.add_child_item(0, sequence2)

    assert sequence2.parent is sequence1
    assert sequence2.root is root
    assert pulse1.index == 1
    assert pulse2.index == 4
    assert (sorted(root.get_accessible_vars()) == sorted(
        ['1_start', '1_stop', '1_duration', '4_start', '4_stop',
         '4_duration']))

    pulse1.index = 200
    sequence2.add_child_item(0, pulse3)

    assert pulse3.parent is sequence2
    assert pulse3.root is root
    assert pulse2.index == 5
    assert pulse3.index == 4
    assert (sorted(root.get_accessible_vars()) == sorted([
        '1_start', '1_stop', '1_duration', '4_start', '4_stop', '4_duration',
        '5_start', '5_stop', '5_duration'
    ]))

    # Check that only the pulse below the modified sequence are updated.
    assert pulse1.index == 200
    pulse1.index = 0

    sequence1.add_child_item(0, pulse4)

    assert pulse4.index == 3
    assert sequence2.index == 4
    assert pulse3.index == 5
    assert pulse2.index == 6
    assert (sorted(root.get_accessible_vars()) == sorted([
        '1_start', '1_stop', '1_duration', '3_start', '3_stop', '3_duration',
        '5_start', '5_stop', '5_duration', '6_start', '6_stop', '6_duration'
    ]))

    sequence1.remove_child_item(1)

    assert sequence2.parent is None
    assert sequence2.index == 0
    assert pulse2.index == 4
    assert (sorted(root.get_accessible_vars()) == sorted([
        '1_start', '1_stop', '1_duration', '3_start', '3_stop', '3_duration',
        '4_start', '4_stop', '4_duration'
    ]))

    sequence1.index = 200
    root2 = RootSequence()
    sequence2.root = root2
    while True:
        sequence2.remove_child_item(0)
        if not sequence2.items:
            break

    # Check the observer was properly removed
    assert sequence1.index == 200
def test_sequence_indexing1():
    """Test adding, moving, deleting pulse in a sequence.

    """
    root = RootSequence()
    root.time_constrained = True
    root.sequence_duration = '1.0'
    context = TestContext()
    root.context = context

    pulse1 = Pulse()
    pulse2 = Pulse()
    pulse3 = Pulse()

    root.add_child_item(0, pulse1)
    assert pulse1.index == 1
    assert pulse1.root is root
    assert (sorted(root.get_accessible_vars()) == (sorted(
        ['sequence_end', '1_start', '1_stop', '1_duration'])))

    root.add_child_item(1, pulse2)
    assert pulse1.index == 1
    assert pulse2.index == 2
    assert pulse2.root is root
    assert (sorted(root.get_accessible_vars()) == sorted([
        'sequence_end', '1_start', '1_stop', '1_duration', '2_start', '2_stop',
        '2_duration'
    ]))

    root.move_child_item(0, 1)
    assert pulse1.index == 2
    assert pulse2.index == 1
    assert (sorted(root.get_accessible_vars()) == sorted([
        'sequence_end', '1_start', '1_stop', '1_duration', '2_start', '2_stop',
        '2_duration'
    ]))

    root.move_child_item(0, 1)

    root.add_child_item(2, pulse3)
    assert pulse1.index == 1
    assert pulse2.index == 2
    assert pulse3.index == 3
    assert pulse3.root is root
    assert (sorted(root.get_accessible_vars()) == sorted([
        'sequence_end', '1_start', '1_stop', '1_duration', '2_start', '2_stop',
        '2_duration', '3_start', '3_stop', '3_duration'
    ]))

    root.time_constrained = False
    root.remove_child_item(1)
    assert pulse1.index == 1
    assert pulse2.index == 0
    assert pulse3.index == 2
    assert pulse2.root is None
    assert (sorted(root.get_accessible_vars()) == sorted(
        ['1_start', '1_stop', '1_duration', '2_start', '2_stop',
         '2_duration']))

    root.add_child_item(1, pulse2)
    assert pulse1.index == 1
    assert pulse2.index == 2
    assert pulse3.index == 3
    assert pulse2.root is root
    assert (sorted(root.get_accessible_vars()) == sorted([
        '1_start', '1_stop', '1_duration', '2_start', '2_stop', '2_duration',
        '3_start', '3_stop', '3_duration'
    ]))