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']
def test_clone_sequence(): _sel00 = AutomaticData(Location='Phys/Sel00') _sel01 = AutomaticData(Location='Phys/Sel01') _sel02 = AutomaticData(Location='Phys/Sel02') _sel03 = AutomaticData(Location='Phys/Sel03') sel01 = Selection('00120', Algorithm=MockConfGenerator(), RequiredSelections=[_sel00, _sel01]) sel02 = Selection('00121', Algorithm=MockConfGenerator(), RequiredSelections=[_sel02, _sel03]) sel03 = Selection('00122', Algorithm=MockConfGenerator(), RequiredSelections=[sel01, sel02]) presel0 = MockConfGenerator() presel1 = MockConfGenerator() postsel0 = MockConfGenerator() postsel1 = MockConfGenerator() presels = [presel0, presel1] postsels = [postsel0, postsel1] seq = SelectionSequence('Seq03', TopSelection=sel03, EventPreSelector=presels, PostSelectionAlgs=postsels, sequencerType=DummySequencer) clone = seq.clone(name='clone') seqAlgos = clone.sequence().Members ref_algos = [ presel0, presel1, _sel00.algorithm(), _sel01.algorithm(), _sel02.algorithm(), _sel03.algorithm(), sel02.algorithm(), sel01.algorithm(), sel03.algorithm(), postsel0, postsel1 ] assert len(seqAlgos) == len(ref_algos) assert presels == seqAlgos[:len(presels)] assert postsels == seqAlgos[len(ref_algos) - len(postsels):] # sel03 must come just before the post selection algos. assert sel03.algorithm() == ref_algos[len(ref_algos) - (len(presels) + 1)] # order of sel01 and sel02 doesn't matter. for sel in [sel01, sel02]: assert sel.algorithm() in ref_algos[len(presels):len(ref_algos) - len(postsels)] seqAlgos = seq.algorithms() assert len(seqAlgos) == len(ref_algos) assert presels == seqAlgos[:len(presels)] assert postsels == seqAlgos[len(ref_algos) - len(postsels):] for sel in [sel01, sel02, sel03]: assert sel.algorithm() in ref_algos[len(presels):len(ref_algos) - len(postsels)]
def test_multi_sequencer_sequences(): _sel00 = AutomaticData(Location='Phys/Sel00') _sel01 = AutomaticData(Location='Phys/Sel01') _sel02 = AutomaticData(Location='Phys/Sel02') _sel03 = AutomaticData(Location='Phys/Sel03') sel00_01 = Selection('0000110', Algorithm=MockConfGenerator(), RequiredSelections=[_sel00, _sel01]) sel02_03 = Selection('0000111', Algorithm=MockConfGenerator(), RequiredSelections=[_sel02, _sel03]) selA = Selection('000112A', Algorithm=MockConfGenerator(), RequiredSelections=[sel00_01, sel02_03]) _sel04 = AutomaticData(Location='Phys/Sel04') _sel05 = AutomaticData(Location='Phys/Sel05') _sel06 = AutomaticData(Location='Phys/Sel06') _sel07 = AutomaticData(Location='Phys/Sel07') sel04_05 = Selection('0000112', Algorithm=MockConfGenerator(), RequiredSelections=[_sel04, _sel05]) sel06_07 = Selection('0000113', Algorithm=MockConfGenerator(), RequiredSelections=[_sel06, _sel07]) selB = Selection('000112B', Algorithm=MockConfGenerator(), RequiredSelections=[sel04_05, sel06_07]) presel0 = MockConfGenerator() presel1 = MockConfGenerator() presel2 = MockConfGenerator() presel3 = MockConfGenerator() postsel0 = MockConfGenerator() postsel1 = MockConfGenerator() postsel2 = MockConfGenerator() postsel3 = MockConfGenerator() preselsA = [presel0, presel1] postselsA = [postsel0, postsel1] preselsB = [presel2, presel3] postselsB = [postsel2, postsel3] seqA = SelectionSequence('Seq0002A', TopSelection=selA, EventPreSelector=preselsA, PostSelectionAlgs=postselsA) seqB = SelectionSequence('Seq0002B', TopSelection=selB, EventPreSelector=preselsB, PostSelectionAlgs=postselsB) multiSeq = MultiSelectionSequence('MultiSeqAB', Sequences=[seqA, seqB], sequencerType=DummySequencer) assert multiSeq.outputLocations() == [ selA.outputLocation(), selB.outputLocation() ] print 'algos in seqA', len(seqA.algorithms()) print 'algos in seqB', len(seqB.algorithms()) seqAlgos = multiSeq.sequence().Members seqAlgosA = seqAlgos[0].Members seqAlgosB = seqAlgos[1].Members assert len(seqAlgos) == len(multiSeq._sequences) assert len(multiSeq.algorithms()) == len(seqAlgosA) + len(seqAlgosB) ref_algosA = [ presel0, presel1, _sel00.algorithm(), _sel01.algorithm(), _sel02.algorithm(), _sel03.algorithm(), sel02_03.algorithm(), sel00_01.algorithm(), selA.algorithm(), postsel0, postsel1 ] ref_algosB = [ presel2, presel3, _sel04.algorithm(), _sel05.algorithm(), _sel06.algorithm(), _sel07.algorithm(), sel06_07.algorithm(), sel04_05.algorithm(), selB.algorithm(), postsel2, postsel3 ] assert len(seqAlgos) == 2 assert preselsA == seqAlgosA[:len(preselsA)] assert preselsB == seqAlgosB[:len(preselsB)] # selA must be just before postsels assert selA.algorithm() == ref_algosA[len(ref_algosA) - (len(postselsA) + 1)] assert postselsA == seqAlgosA[len(ref_algosA) - len(postselsA):] assert postselsB == seqAlgosB[len(ref_algosB) - len(postselsB):] # selB must be just before postsels assert selB.algorithm() == ref_algosB[len(ref_algosB) - (len(postselsB) + 1)] # order doesn't matter for sel in [sel04_05, sel06_07]: assert sel.algorithm() in ref_algosB[len(preselsB):len(ref_algosB) - len(postselsB)] for sel in [sel00_01, sel02_03]: assert sel.algorithm() in ref_algosA[len(preselsA):len(ref_algosA) - len(postselsA)]