Exemplo n.º 1
0
def test_instantiate_multi_sequencer():
    sel00 = AutomaticData(Location='Phys/Sel00')
    sel01 = AutomaticData(Location='Phys/Sel01')
    alg00 = MockConfGenerator()
    alg01 = MockConfGenerator()
    sel00 = Selection('100011', Algorithm=alg00, RequiredSelections=[sel00])
    sel01 = Selection('100012', Algorithm=alg01, RequiredSelections=[sel01])
    seq00 = SelectionSequence('Seq000', TopSelection=sel00)
    seq01 = SelectionSequence('Seq001', TopSelection=sel01)
    seq = MultiSelectionSequence('MultiSeq00z', Sequences=[seq00, seq01])
Exemplo n.º 2
0
def test_PassThroughSelection_name():
    alg = MockConfGenerator()
    reqSel = AutomaticData(Location='PassThroughDOD')
    sel = PassThroughSelection('PTSelNameTest',
                               ConfGenerator=alg,
                               RequiredSelection=reqSel)
    assert sel.name() == 'PTSelNameTest'
Exemplo n.º 3
0
def test_EventSelection():
    alg = MockConfGenerator()
    evtSel = EventSelection('DummyEvtSel', Algorithm=alg)
    newSel = dummy('NewEvtSel', evtSel)
    assert newSel.selection().name() == 'DummyEvtSel'
    assert newSel.outputLocation() == ''
    assert len(newSel.members()) == 1
Exemplo n.º 4
0
def test_PassThroughSelection_outputLocation():
    alg = MockConfGenerator()
    reqSel = AutomaticData(Location='Pass/Through/DOD')
    sel = PassThroughSelection('PTSelOutputTest',
                               ConfGenerator=alg,
                               RequiredSelection=reqSel)
    assert sel.outputLocation() == 'Pass/Through/DOD'
def test_EventSelection_duplicate_name_raises():
    alg = MockConfGenerator()
    es = EventSelection('EvtUniqueSelNameTest', ConfGenerator=alg)
    raises(NameError,
           EventSelection,
           'EvtUniqueSelNameTest',
           ConfGenerator=alg)
Exemplo n.º 6
0
def test_clone_PassThroughSelection_with_used_name_raises():
    alg = MockConfGenerator()
    reqSel = AutomaticData(Location='Pass/Through/DOD')
    sel = PassThroughSelection('PTSelCloneTest2',
                               ConfGenerator=alg,
                               RequiredSelection=reqSel,
                               InputDataSetter='INPUTS')
    raises(NameError, sel.clone, name='PTSelCloneTest2')
Exemplo n.º 7
0
def test_PassThroughSelection_outputLocation_with_user_defined_datasetter():
    alg = MockConfGenerator()
    reqSel = AutomaticData(Location='Pass/Through/DOD')
    sel = PassThroughSelection('PTSelInputTest',
                               ConfGenerator=alg,
                               RequiredSelection=reqSel,
                               InputDataSetter='TESTINPUTS')
    assert sel.algorithm().TESTINPUTS == [reqSel.outputLocation()]
Exemplo n.º 8
0
def test_Selection_output_data_setter():
    alg = MockConfGenerator()
    sel0 = AutomaticData('Phys/Hello/World/0')
    sel1 = AutomaticData('Phys/Hello/World/1')
    sel = Selection('SelOutputTest6',
                    ConfGenerator=alg,
                    RequiredSelections=[sel0, sel1])
    assert sel.algorithm().Output == sel.outputLocation()
Exemplo n.º 9
0
def test_selection_with_name_overlap_doesnt_raise():
    sel02 = AutomaticData(Location='Phys/Sel02/Particles')
    sel03 = AutomaticData(Location='Phys/Sel03/Particles')
    alg0 = MockConfGenerator()
    sel0 = Selection('Sel005', Algorithm=alg0)
    sel1 = Selection('Sel005Loose', Algorithm=alg0)
    assert sel0.outputLocation() == 'Phys/Sel005/Particles'
    assert sel1.outputLocation() == 'Phys/Sel005Loose/Particles'
Exemplo n.º 10
0
def test_Selection_outputLocation_with_user_defined_extension_and_no_branch():
    alg = MockConfGenerator()
    sel = Selection('SelOutputTest3',
                    ConfGenerator=alg,
                    OutputBranch='',
                    Extension='Tracks')
    assert sel.outputLocation() == 'SelOutputTest3/Tracks'
    assert sel.outputLocation() == sel.algorithm().Output
Exemplo n.º 11
0
def test_Selection_outputLocation_with_no_branch_and_no_extension():
    alg = MockConfGenerator()
    sel = Selection('SelOutputTest4',
                    ConfGenerator=alg,
                    OutputBranch='',
                    Extension='')
    assert sel.outputLocation() == 'SelOutputTest4'
    assert sel.outputLocation() == sel.algorithm().Output
Exemplo n.º 12
0
def test_selection_with_same_Inputs_set_in_algo():
    sel02 = AutomaticData(Location='Phys/Sel02/Particles')
    sel03 = AutomaticData(Location='Phys/Sel03/Particles')
    alg0 = MockConfGenerator(
        Inputs=['Phys/Sel02/Particles', 'Phys/Sel03/Particles'])
    sel0 = Selection('Sel007',
                     Algorithm=alg0,
                     RequiredSelections=[sel02, sel03])
class SelectionTree(object):
    sel000 = Selection('0.00000',
                       Algorithm=MockConfGenerator(),
                       RequiredSelections=[])
    sel001 = Selection('0.00001',
                       Algorithm=MockConfGenerator(),
                       RequiredSelections=[])
    sel002 = Selection('0.00002',
                       Algorithm=MockConfGenerator(),
                       RequiredSelections=[])
    sel003 = Selection('0.00003',
                       Algorithm=MockConfGenerator(),
                       RequiredSelections=[])

    sel100 = Selection('1.00000',
                       Algorithm=MockConfGenerator(),
                       RequiredSelections=[sel000, sel001])

    sel101 = Selection('1.00001',
                       Algorithm=MockConfGenerator(),
                       RequiredSelections=[sel002, sel003])

    sel200 = Selection('2.00000',
                       Algorithm=MockConfGenerator(),
                       RequiredSelections=[sel100, sel101])

    selSeq = SelectionSequence('Seq06', TopSelection=sel200)
    algs = selSeq.algorithms()
    alg_names = [a.name() for a in algs]
Exemplo n.º 14
0
class SelectionTree(object):
    sel000 = Selection('0.00000',
                       ConfGenerator=MockConfGenerator(),
                       RequiredSelections=[])
    sel001 = Selection('0.00001',
                       ConfGenerator=MockConfGenerator(),
                       RequiredSelections=[])
    sel002 = Selection('0.00002',
                       ConfGenerator=MockConfGenerator(),
                       RequiredSelections=[])
    sel003 = Selection('0.00003',
                       ConfGenerator=MockConfGenerator(),
                       RequiredSelections=[])

    sel100 = Selection('1.00000',
                       ConfGenerator=MockConfGenerator(),
                       RequiredSelections=[sel000, sel001])

    sel101 = Selection('1.00001',
                       ConfGenerator=MockConfGenerator(),
                       RequiredSelections=[sel002, sel003])

    sel200 = Selection('2.00000',
                       ConfGenerator=MockConfGenerator(),
                       RequiredSelections=[sel100, sel101])

    algos = flatAlgorithmList(sel200)
    alg_names = [a.name() for a in algos]
Exemplo n.º 15
0
def test_Selection_with_user_defined_output_data_setter():
    alg = MockConfGenerator()
    sel0 = AutomaticData('Phys/Hello/World/0')
    sel1 = AutomaticData('Phys/Hello/World/1')
    sel = Selection('SelOutputTest8',
                    ConfGenerator=alg,
                    RequiredSelections=[sel0, sel1],
                    OutputDataSetter='TESTOUTPUTS')
    assert sel.algorithm().TESTOUTPUTS == sel.outputLocation()
Exemplo n.º 16
0
def test_selection_with_incompatible_Inputs_set_in_algo_raises():
    sel02 = AutomaticData(Location='Phys/Sel02')
    sel03 = AutomaticData(Location='Phys/Sel03')
    alg0 = MockConfGenerator(Inputs=['Phys/Sel00', 'Phys/Sel01'])
    raises(IncompatibleInputLocations,
           Selection,
           'SelInputCompatTest',
           ConfGenerator=alg0,
           RequiredSelections=[sel02, sel03])
Exemplo n.º 17
0
def test_selection_with_incompatible_Output_set_in_algo_raises():
    sel02 = AutomaticData(Location='Phys/Sel02')
    sel03 = AutomaticData(Location='Phys/Sel03')
    alg = MockConfGenerator(Output='Hello/World')
    raises(IncompatibleOutputLocation,
           Selection,
           'SelOutputCompatTest',
           ConfGenerator=alg,
           RequiredSelections=[sel02, sel03])
Exemplo n.º 18
0
def test_clone_selection_with_new_alg():
    sel0 = test_instantiate_tree('0001')
    alg1 = MockConfGenerator(Inputs=[])
    selClone = sel0.clone(name='sel0_clone0', Algorithm=alg1)
    assert len(alg1.Inputs) == 0

    assert len(sel0.algorithm().Inputs) == 2
    assert sel0.algorithm().Inputs.count('Phys/Sel00/Particles') == 1
    assert sel0.algorithm().Inputs.count('Phys/Sel01/Particles') == 1
Exemplo n.º 19
0
def test_dummy_selection():
    data0 = AutomaticData(Location='Phys/Data0')
    data1 = AutomaticData(Location='Phys/Data1')
    algo = MockConfGenerator()
    sel = Selection('Sel01', Algorithm=algo, RequiredSelections=[data0, data1])
    newData = dummy('NewSel01', sel)
    assert newData.selection().name() == 'NewSel01'
    assert newData.outputLocation() == newData.selection().outputLocation(
    ) == 'Phys/NewSel01/Particles'
    assert len(newData.members()) == 3
Exemplo n.º 20
0
def test_PassThroughSelection():
    alg = MockConfGenerator()
    data0 = AutomaticData(Location='Phys/Data0')
    evtSel = PassThroughSelection('TestPassThrough',
                                  Algorithm=alg,
                                  RequiredSelection=data0)
    newSel = dummy('NewEvtSel', evtSel)
    assert newSel.selection().name() == 'NewEvtSel'
    assert newSel.outputLocation() == 'Phys/NewEvtSel/Particles'
    assert len(newSel.members()) == 1
Exemplo n.º 21
0
def test_outputLocation():
    sel00 = AutomaticData(Location='Phys/Sel00/Particles')
    assert sel00.outputLocation() == 'Phys/Sel00/Particles'
    alg0 = MockConfGenerator()
    sel0 = Selection('SomeName001', Algorithm=alg0)
    assert sel0.outputLocation() == 'Phys/SomeName001/Particles'
    sel1 = Selection('SomeName002',
                     OutputBranch='HLT2',
                     Algorithm=alg0,
                     Extension='HltParticles')
    assert sel1.outputLocation() == 'HLT2/SomeName002/HltParticles'
Exemplo n.º 22
0
def test_PassThroughSelection_duplicate_name_raises():
    alg = MockConfGenerator()
    reqSel = AutomaticData(Location='PassThroughDOD')
    es = PassThroughSelection('PTUniqueSelNameTest',
                              ConfGenerator=alg,
                              RequiredSelection=reqSel)
    raises(NameError,
           PassThroughSelection,
           'PTUniqueSelNameTest',
           ConfGenerator=alg,
           RequiredSelection=reqSel)
Exemplo n.º 23
0
def test_Selection_does_not_modify_generator():
    alg = MockConfGenerator()
    sel0 = AutomaticData('Phys/Hello/World/0')
    sel1 = AutomaticData('Phys/Hello/World/1')
    sel = Selection('SelGenTest',
                    ConfGenerator=alg,
                    RequiredSelections=[sel0, sel1])
    assert sel.algorithm().Inputs == [
        sel0.outputLocation(), sel1.outputLocation()
    ]
    assert hasattr(alg, 'Output') == False
Exemplo n.º 24
0
def test_flatAlgorithmList_order_line():

    sel000 = Selection('0.0000',
                       ConfGenerator=MockConfGenerator(),
                       RequiredSelections=[])
    sel001 = Selection('0.0001',
                       ConfGenerator=MockConfGenerator(),
                       RequiredSelections=[sel000])
    sel101 = Selection('1.0000',
                       ConfGenerator=MockConfGenerator(),
                       RequiredSelections=[sel001])
    sel102 = Selection('1.0001',
                       ConfGenerator=MockConfGenerator(),
                       RequiredSelections=[sel101])
    sel203 = Selection('2.0000',
                       ConfGenerator=MockConfGenerator(),
                       RequiredSelections=[sel102])

    algos = flatAlgorithmList(sel203)
    assert [a.name() for a in algos
            ] == ['0.0000', '0.0001', '1.0000', '1.0001', '2.0000']
Exemplo n.º 25
0
def test_tree_Inputs_propagated():

    sel00 = AutomaticData(Location='Phys/Sel00/Particles')
    sel01 = AutomaticData(Location='Phys/Sel01/Particles')
    alg0 = MockConfGenerator(Inputs=[])
    sel0 = Selection('Sel001',
                     Algorithm=alg0,
                     RequiredSelections=[sel00, sel01])
    assert len(alg0.Inputs) == 0
    assert len(sel0.algorithm().Inputs) == 2
    assert sel0.algorithm().Inputs.count('Phys/Sel00/Particles') == 1
    assert sel0.algorithm().Inputs.count('Phys/Sel01/Particles') == 1
Exemplo n.º 26
0
def test_clone_PassThroughSelection():
    alg = MockConfGenerator()
    reqSel = AutomaticData(Location='Pass/Through/DOD')
    sel = PassThroughSelection('PTSelCloneTest',
                               ConfGenerator=alg,
                               RequiredSelection=reqSel,
                               InputDataSetter='INPUTS')
    selClone = sel.clone(name='PTSelCloneTestClone')
    assert selClone.outputLocation() == sel.outputLocation()
    assert selClone.requiredSelections() == sel.requiredSelections()
    assert selClone.algorithm().INPUTS == sel.algorithm().INPUTS
    assert selClone.algorithm() != sel.algorithm()
def test_remove_duplicates():

    sel000 = SelectionTree.sel000
    sel001 = SelectionTree.sel001
    sel002 = SelectionTree.sel002
    sel003 = SelectionTree.sel003

    sel100 = Selection('1.10000',
                       Algorithm=MockConfGenerator(),
                       RequiredSelections=[sel000, sel001, sel002])

    sel101 = Selection('1.10001',
                       Algorithm=MockConfGenerator(),
                       RequiredSelections=[sel001, sel002, sel003])

    sel200 = Selection('2.10000',
                       Algorithm=MockConfGenerator(),
                       RequiredSelections=[sel100, sel101])

    selSeq = SelectionSequence('Seq07', TopSelection=sel200)
    algs = selSeq.algorithms()
    alg_names = [a.name() for a in algs]

    assert len(algs) == 7
    assert alg_names.count('0.00000') == 1
    assert alg_names.count('0.00001') == 1
    assert alg_names.count('0.00002') == 1
    assert alg_names.count('0.00003') == 1
    assert alg_names.count('1.10000') == 1
    assert alg_names.count('1.10001') == 1
    assert alg_names.count('2.10000') == 1

    assert alg_names.index('0.00000') < alg_names.index('1.10000')
    assert alg_names.index('0.00001') < alg_names.index('1.10000')
    assert alg_names.index('0.00002') < alg_names.index('1.10000')
    assert alg_names.index('0.00001') < alg_names.index('1.10001')
    assert alg_names.index('0.00002') < alg_names.index('1.10001')
    assert alg_names.index('0.00003') < alg_names.index('1.10001')
    assert alg_names.index('1.10000') < alg_names.index('2.10000')
    assert alg_names.index('1.10001') < alg_names.index('2.10000')
def test_sequencer_algos():
    _sel00 = AutomaticData(Location='Phys/Sel00')
    _sel01 = AutomaticData(Location='Phys/Sel01')
    _sel02 = AutomaticData(Location='Phys/Sel02')
    _sel03 = AutomaticData(Location='Phys/Sel03')

    sel01 = Selection('00100',
                      Algorithm=MockConfGenerator(),
                      RequiredSelections=[_sel00, _sel01])
    sel02 = Selection('00101',
                      Algorithm=MockConfGenerator(),
                      RequiredSelections=[_sel02, _sel03])
    sel03 = Selection('00102',
                      Algorithm=MockConfGenerator(),
                      RequiredSelections=[sel01, sel02])
    seq = SelectionSequence('Seq01', TopSelection=sel03)

    seqAlgos = seq.algorithms()

    assert len(seqAlgos) == 7
    for sel in [sel01, sel02, sel03]:
        assert sel.algorithm() in seqAlgos
def test_order_line():

    sel000 = Selection('0.0000',
                       Algorithm=MockConfGenerator(),
                       RequiredSelections=[])
    sel001 = Selection('0.0001',
                       Algorithm=MockConfGenerator(),
                       RequiredSelections=[sel000])
    sel101 = Selection('1.0000',
                       Algorithm=MockConfGenerator(),
                       RequiredSelections=[sel001])
    sel102 = Selection('1.0001',
                       Algorithm=MockConfGenerator(),
                       RequiredSelections=[sel101])
    sel203 = Selection('2.0000',
                       Algorithm=MockConfGenerator(),
                       RequiredSelections=[sel102])

    selSeq = SelectionSequence('Seq04', TopSelection=sel203)
    algs = selSeq.algorithms()
    assert [a.name() for a in algs
            ] == ['0.0000', '0.0001', '1.0000', '1.0001', '2.0000']
Exemplo n.º 30
0
def test_flatAlgorithmList_removes_duplicates():

    sel000 = SelectionTree.sel000
    sel001 = SelectionTree.sel001
    sel002 = SelectionTree.sel002
    sel003 = SelectionTree.sel003

    sel100 = Selection('1.10000',
                       ConfGenerator=MockConfGenerator(),
                       RequiredSelections=[sel000, sel001, sel002])

    sel101 = Selection('1.10001',
                       ConfGenerator=MockConfGenerator(),
                       RequiredSelections=[sel001, sel002, sel003])

    sel200 = Selection('2.10000',
                       ConfGenerator=MockConfGenerator(),
                       RequiredSelections=[sel100, sel101])

    algos = flatAlgorithmList(sel200)
    alg_names = [a.name() for a in algos]
    assert len(algos) == 7
    assert alg_names.count('0.00000') == 1
    assert alg_names.count('0.00001') == 1
    assert alg_names.count('0.00002') == 1
    assert alg_names.count('0.00003') == 1
    assert alg_names.count('1.10000') == 1
    assert alg_names.count('1.10001') == 1
    assert alg_names.count('2.10000') == 1

    assert alg_names.index('0.00000') < alg_names.index('1.10000')
    assert alg_names.index('0.00001') < alg_names.index('1.10000')
    assert alg_names.index('0.00002') < alg_names.index('1.10000')
    assert alg_names.index('0.00001') < alg_names.index('1.10001')
    assert alg_names.index('0.00002') < alg_names.index('1.10001')
    assert alg_names.index('0.00003') < alg_names.index('1.10001')
    assert alg_names.index('1.10000') < alg_names.index('2.10000')
    assert alg_names.index('1.10001') < alg_names.index('2.10000')