本文整理汇总了Python中WMCore.DataStructs.LumiList.LumiList类的典型用法代码示例。如果您正苦于以下问题:Python LumiList类的具体用法?Python LumiList怎么用?Python LumiList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LumiList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testWithMaskedBlocks
def testWithMaskedBlocks(self):
"""
_testWithMaskedBlocks_
Test job splitting with masked blocks
"""
Globals.GlobalParams.setNumOfRunsPerFile(3)
Globals.GlobalParams.setNumOfLumisPerBlock(5)
rerecoArgs["ConfigCacheID"] = createConfig(rerecoArgs["CouchDBName"])
factory = ReRecoWorkloadFactory()
Tier1ReRecoWorkload = factory.factoryWorkloadConstruction('ReRecoWorkload', rerecoArgs)
Tier1ReRecoWorkload.data.request.priority = 69
task = getFirstTask(Tier1ReRecoWorkload)
inputDataset = task.inputDataset()
task.data.input.splitting.runs = [181061, 180899]
task.data.input.splitting.lumis = ['1,50,60,70', '1,1']
lumiMask = LumiList(compactList = {'206371': [[1, 50], [60,70]], '180899':[[1,1]], } )
dataset = "/%s/%s/%s" % (inputDataset.primary,
inputDataset.processed,
inputDataset.tier)
dbs = {inputDataset.dbsurl : DBSReader(inputDataset.dbsurl)}
units, rejectedWork = Block(**self.splitArgs)(Tier1ReRecoWorkload, task)
nLumis = 0
for unit in units:
nLumis += unit['NumberOfLumis']
self.assertEqual(len(lumiMask.getLumis()), nLumis)
示例2: mergeLumis
def mergeLumis(inputdata, lumimask):
"""
Computes the processed lumis, merges if needed and returns the compacted list (called when usedbs=no).
"""
doubleLumis = set()
mergedLumis = set()
#merge the lumis from single files
for reports in inputdata.values():
for report in reports:
for run, lumis in literal_eval(report['runlumi']).iteritems():
for lumi in lumis:
if (run,lumi) in mergedLumis:
doubleLumis.add((run,lumi))
mergedLumis.add((run,lumi))
#convert the runlumis from list of pairs to dict: [(123,3), (123,4), (123,5), (123,7), (234,6)] => {123 : [3,4,5,7], 234 : [6]}
dLumisDict = {}
mLumisDict = {}
for k, v in doubleLumis:
dLumisDict.setdefault(k, []).append(int(v))
for k, v in mergedLumis:
mLumisDict.setdefault(k, []).append(int(v))
doubleLumis = LumiList(runsAndLumis=dLumisDict)
mergedLumis = LumiList(runsAndLumis=mLumisDict)
#get the compact list using CMSSW framework
return mergedLumis.getCompactList(), (LumiList(compactList=lumimask) - mergedLumis).getCompactList(), doubleLumis.getCompactList()
示例3: fast_getDoubleLumis
def fast_getDoubleLumis(lumisDict):
doubleLumis = set()
for run, lumis in lumisDict.iteritems():
seen = set()
doubleLumis.update(set((run, lumi) for lumi in lumis if (run, lumi) in seen or seen.add((run, lumi))))
doubleLumis = LumiList(lumis=doubleLumis)
return doubleLumis.getCompactList()
示例4: testOr
def testOr(self):
"""
a|b for lots of cases
"""
alumis = {'1' : range(2,20) + range(31,39) + range(45,49),
'2' : range(6,20) + range (30,40),
'3' : range(10,20) + range (30,40) + range(50,60),
}
blumis = {'1' : range(1,6) + range(12,13) + range(16,30) + range(40,50) + range(39,80),
'2' : range(10,35),
'3' : range(10,15) + range(35,40) + range(45,51) + range(59,70),
}
clumis = {'1' : range(1,6) + range(12,13) + range(16,30) + range(40,50) + range(39,80),
'2' : range(10,35),
}
result = {'1' : range(2,20) + range(31,39) + range(45,49) + range(1,6) + range(12,13) + range(16,30) + range(40,50) + range(39,80),
'2' : range(6,20) + range (30,40) + range(10,35),
'3' : range(10,20) + range (30,40) + range(50,60) + range(10,15) + range(35,40) + range(45,51) + range(59,70),
}
a = LumiList(runsAndLumis = alumis)
b = LumiList(runsAndLumis = blumis)
c = LumiList(runsAndLumis = blumis)
r = LumiList(runsAndLumis = result)
self.assertTrue((a|b).getCMSSWString() == r.getCMSSWString())
self.assertTrue((a|b).getCMSSWString() == (b|a).getCMSSWString())
self.assertTrue((a|b).getCMSSWString() == (a+b).getCMSSWString())
# Test list constuction (faster)
multiple = [alumis, blumis, clumis]
easy = LumiList(runsAndLumis = multiple)
hard = a + b
hard += c
self.assertTrue(hard.getCMSSWString() == easy.getCMSSWString())
示例5: testAnd
def testAnd(self):
"""
a&b for lots of cases
"""
alumis = {'1' : range(2,20) + range(31,39) + range(45,49),
'2' : range(6,20) + range (30,40),
'3' : range(10,20) + range (30,40) + range(50,60),
'4' : range(1,100),
}
blumis = {'1' : range(1,6) + range(12,13) + range(16,25) + range(25,40) + range(40,50) + range(33,36),
'2' : range(10,35),
'3' : range(10,15) + range(35,40) + range(45,51) + range(59,70),
'5' : range(1,100),
}
result = {'1' : range(2,6) + range(12,13) + range(16,20) + range(31,39) + range(45,49),
'2' : range(10,20) + range(30,35),
'3' : range(10,15) + range(35,40) + range(50,51)+ range(59,60),
}
a = LumiList(runsAndLumis = alumis)
b = LumiList(runsAndLumis = blumis)
r = LumiList(runsAndLumis = result)
self.assertTrue((a&b).getCMSSWString() == r.getCMSSWString())
self.assertTrue((a&b).getCMSSWString() == (b&a).getCMSSWString())
self.assertTrue((a|b).getCMSSWString() != r.getCMSSWString())
示例6: testFilter
def testFilter(self):
"""
Test filtering of a list of lumis
"""
runsAndLumis = {
1: range(1, 34) + [35] + range(37, 48),
2: range(49, 76) + range(77, 131) + range(133, 137)
}
completeList = zip([1]*150, range(1, 150)) + \
zip([2]*150, range(1, 150)) + \
zip([3]*150, range(1, 150))
smallList = zip([1]*50, range(1, 10)) + zip([2]*50, range(50, 70))
overlapList = zip([1]*150, range(30, 40)) + \
zip([2]*150, range(60, 80))
overlapRes = zip([1]*9, range(30, 34)) + [(1, 35)] + \
zip([1]*9, range(37, 40)) + \
zip([2]*30, range(60, 76)) + \
zip([2]*9, range(77, 80))
runLister = LumiList(runsAndLumis = runsAndLumis)
# Test a list to be filtered which is a superset of constructed list
filterComplete = runLister.filterLumis(completeList)
# Test a list to be filtered which is a subset of constructed list
filterSmall = runLister.filterLumis(smallList)
# Test a list to be filtered which is neither
filterOverlap = runLister.filterLumis(overlapList)
self.assertTrue(filterComplete == runLister.getLumis())
self.assertTrue(filterSmall == smallList)
self.assertTrue(filterOverlap == overlapRes)
示例7: testWithMaskedBlocks
def testWithMaskedBlocks(self):
"""
_testWithMaskedBlocks_
Test job splitting with masked blocks
"""
rerecoArgs["ConfigCacheID"] = createConfig(rerecoArgs["CouchDBName"])
factory = ReRecoWorkloadFactory()
Tier1ReRecoWorkload = factory.factoryWorkloadConstruction('ReRecoWorkload', rerecoArgs)
Tier1ReRecoWorkload.data.request.priority = 69
task = getFirstTask(Tier1ReRecoWorkload)
dummyDataset = task.inputDataset()
task.data.input.splitting.runs = [181061, 180899]
task.data.input.splitting.lumis = ['1,50,60,70', '1,1']
lumiMask = LumiList(compactList={'206371': [[1, 50], [60, 70]], '180899': [[1, 1]], })
units, dummyRejectedWork = Block(**self.splitArgs)(Tier1ReRecoWorkload, task)
nLumis = 0
for unit in units:
nLumis += unit['NumberOfLumis']
self.assertEqual(len(lumiMask.getLumis()), nLumis)
示例8: subtractLumis
def subtractLumis(input, output):
"""
Computes the processed lumis, merges from the DBS reuslts (called when usedbs=yes).
"""
out = LumiList(runsAndLumis=output)
in_ = LumiList(runsAndLumis=input)
diff = in_ - out
return out.getCompactList(), diff.getCompactList()
示例9: getDoubleLumis
def getDoubleLumis(lumisDict):
#calculate lumis counted twice
doubleLumis = set()
for run, lumis in lumisDict.iteritems():
seen = set()
doubleLumis.update(set((run, lumi) for lumi in lumis if (run, lumi) in seen or seen.add((run, lumi))))
doubleLumis = LumiList(lumis=doubleLumis)
return doubleLumis.getCompactList()
示例10: makeLumiList
def makeLumiList(lumiDict):
try:
if isinstance(lumiDict, basestring):
lumiDict = JsonWrapper.loads(lumiDict)
ll = LumiList(compactList=lumiDict)
return ll.getCompactList()
except:
raise WMSpecFactoryException("Could not parse LumiList, %s: %s" % (type(lumiDict), lumiDict))
示例11: testWrite
def testWrite(self):
alumis = {'1' : range(2,20) + range(31,39) + range(45,49),
'2' : range(6,20) + range (30,40),
'3' : range(10,20) + range (30,40) + range(50,60),
'4' : range(1,100),
}
a = LumiList(runsAndLumis = alumis)
a.writeJSON('newFile.json')
示例12: testWrite
def testWrite(self):
alumis = {
"1": range(2, 20) + range(31, 39) + range(45, 49),
"2": range(6, 20) + range(30, 40),
"3": range(10, 20) + range(30, 40) + range(50, 60),
"4": range(1, 100),
}
a = LumiList(runsAndLumis=alumis)
a.writeJSON("newFile.json")
示例13: getDoubleLumis
def getDoubleLumis(lumisDict):
#calculate lumis counted twice
doubleLumis = set()
for run, lumis in lumisDict.iteritems():
for lumi in lumis:
if lumisDict[run].count(lumi) > 1:
doubleLumis.add((run,lumi))
doubleLumis = LumiList(lumis=doubleLumis)
return doubleLumis.getCompactList()
示例14: testDuplicates
def testDuplicates(self):
"""
Test a list with lots of duplicates
"""
result = zip([1]*100, range(1, 34) + range(37, 48))
lumis = zip([1]*100, range(1, 34) + range(37, 48) + range(5, 25))
lister = LumiList(lumis = lumis)
self.assertTrue(lister.getLumis() == result)
示例15: testNull
def testNull(self):
"""
Test a null list
"""
runLister = LumiList(lumis = None)
self.assertTrue(runLister.getCMSSWString() == '')
self.assertTrue(runLister.getLumis() == [])
self.assertTrue(runLister.getCompactList() == {})