def split(self, n, nSub=None): ''' Split sample into n sub-samples ''' if n == 1: return self if not n >= 1: raise ValueError("Can not split into: '%r'" % n) chunks = helpers.partition(self.files, min(n, len(self.files))) splitSamps = [ FWLiteSample(name=self.name + "_%i" % n_sample, files=chunks[n_sample], color=self.color, texName=self.texName) for n_sample in xrange(len(chunks)) ] if nSub == None: return splitSamps else: if nSub < len(chunks): return splitSamps[nSub] else: return None
def split( self, n, nSub=None, clear = True, shuffle = False): ''' Split sample into n sub-samples ''' if n==1: return self if not n>=1: raise ValueError( "Can not split into: '%r'" % n ) files = self.files if shuffle: random.shuffle( files ) chunks = helpers.partition( files, min(n , len(files) ) ) if clear: self.clear() # Kill yourself. if nSub == None: return [ HEPMCSample( name = self.name+"_%i" % n_sample, files = chunks[n_sample], normalization = self.normalization, isData = self.isData, color = self.color, texName = self.texName ) for n_sample in xrange(len(chunks)) ] else: return HEPMCSample( name = self.name, files = chunks[nSub], normalization = self.normalization, isData = self.isData, color = self.color, texName = self.texName )
def split(self, n, nSub=None, clear=True, shuffle=False): ''' Split sample into n sub-samples ''' if n == 1: return self if not n >= 1: raise ValueError("Can not split into: '%r'" % n) files = self.files if shuffle: random.shuffle(files) chunks = helpers.partition(files, min(n, len(files))) if clear: self.clear() # Kill yourself. if nSub == None: return [ HEPMCSample(name=self.name + "_%i" % n_sample, files=chunks[n_sample], normalization=self.normalization, isData=self.isData, color=self.color, texName=self.texName) for n_sample in xrange(len(chunks)) ] else: return HEPMCSample(name=self.name, files=chunks[nSub], normalization=self.normalization, isData=self.isData, color=self.color, texName=self.texName)
def split(self, n, nSub=None, clear=True, shuffle=False): ''' Split sample into n sub-samples ''' if n == 1: return self if not n >= 1: raise ValueError("Cannot split into: '%r'" % n) files = self.files if shuffle: random.shuffle(files) chunks = helpers.partition(files, min(n, len(files))) if clear: self.clear() # Kill yourself. splitSamps = [ Sample(name=self.name + "_%i" % n_sample, treeName=self.treeName, files=chunks[n_sample], xSection=self.xSection, normalization=self.normalization, selectionString=self.selectionString, weightString=self.weightString, isData=self.isData, color=self.color, texName=self.texName) for n_sample in xrange(len(chunks)) ] if hasattr(self, 'json'): for s in splitSamps: s.json = self.json if nSub == None: return splitSamps else: if nSub < len(chunks): return splitSamps[nSub] else: return None
def split(self, n, nSub = None, clear = True, shuffle = False): ''' Split sample into n sub-samples ''' if n==1: return self if not n>=1: raise ValueError( "Cannot split into: '%r'" % n ) files = self.files if shuffle: random.shuffle( files ) chunks = helpers.partition( files, min(n , len(files) ) ) if clear: self.clear() # Kill yourself. splitSamps = [Sample( name = self.name + "_%i" % n_sample, treeName = self.treeName, files = chunks[n_sample], xSection = self.xSection, normalization = self.normalization, selectionString = self.selectionString, weightString = self.weightString, isData = self.isData, color = self.color, texName = self.texName) for n_sample in xrange(len(chunks))] if hasattr(self, 'json'): for s in splitSamps: s.json = self.json if nSub == None: return splitSamps else: if nSub<len(chunks): return splitSamps[nSub] else: return None
def split( self, n, nSub = None): ''' Split sample into n sub-samples ''' if n==1: return self if not n>=1: raise ValueError( "Can not split into: '%r'" % n ) chunks = helpers.partition( self.files, min(n , len(self.files) ) ) splitSamps = [ FWLiteSample( name = self.name+"_%i" % n_sample, files = chunks[n_sample], color = self.color, texName = self.texName ) for n_sample in xrange(len(chunks)) ] if nSub == None: return splitSamps else: if nSub<len(chunks): return splitSamps[nSub] else: return None
for c in channels: logger.debug("Queuing jobs for channel %s", c) jobs.append((region, c, setup, False)) for var in variations: jobs.append( (region, c, setup.sysClone(sys={"reweight": [var]}), False)) logger.debug("Queuing jobs for channel %s", c) jobs.append((noRegions[0], "all", setupIncl, True)) for var in variations: jobs.append((noRegions[0], "all", setupIncl.sysClone(sys={"reweight": [var]}), True)) logger.info("Created %s jobs", len(jobs)) jobs = partition(jobs, args.nJobs)[args.job] logger.info("Running over %s jobs", len(jobs)) if not args.combine: if args.cores == 1: results = map(wrapper, jobs) else: from multiprocessing import Pool pool = Pool(processes=args.cores) results = pool.map(wrapper, jobs) pool.close() pool.join() logger.info("All done.")