def _inference(self, start, lbview, quiet=False):
<EOL>gen = xrange(self.checkpoint.arr, self.params.nquartets, self._chunksize)<EOL>njobs = sum(<NUM_LIT:1> for _ in gen)<EOL>jobiter = iter(gen)<EOL>LOGGER.info("<STR_LIT>",self._chunksize, self.checkpoint.arr, self.params.nquartets, njobs)<EOL>key = "<STR_LIT>".format(self.checkpoint.boots)<EOL>with h5py.File(self.database.output, '<STR_LIT>') as out:<EOL><INDENT>if key not in out["<STR_LIT>"].keys():<EOL><INDENT>out["<STR_LIT>"].create_dataset(key, <EOL>(self.params.nquartets, <NUM_LIT:4>), <EOL>dtype=np.uint32, <EOL>chunks=(self._chunksize, <NUM_LIT:4>))<EOL><DEDENT><DEDENT>elapsed = datetime.timedelta(seconds=int(time.time()-start))<EOL>if not self.checkpoint.boots:<EOL><INDENT>printstr = "<STR_LIT>"<EOL>if not quiet:<EOL><INDENT>progressbar(<NUM_LIT:1>, <NUM_LIT:0>, printstr.format(elapsed), spacer="<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>printstr = "<STR_LIT>"<EOL>if not quiet:<EOL><INDENT>progressbar(self.params.nboots, self.checkpoint.boots, <EOL>printstr.format(self.checkpoint.boots, elapsed), spacer="<STR_LIT>")<EOL><DEDENT><DEDENT>res = {}<EOL>for _ in xrange(njobs):<EOL><INDENT>qidx = jobiter.next()<EOL>LOGGER.info('<STR_LIT>', qidx)<EOL>with h5py.File(self.database.input, '<STR_LIT:r>') as inh5:<EOL><INDENT>smps = inh5["<STR_LIT>"][qidx:qidx+self._chunksize]<EOL>res[qidx] = lbview.apply(nworker, *[self, smps, TESTS])<EOL><DEDENT><DEDENT>done = <NUM_LIT:0><EOL>while <NUM_LIT:1>:<EOL><INDENT>curkeys = res.keys()<EOL>finished = [i.ready() for i in res.values()]<EOL>if any(finished):<EOL><INDENT>for ikey in curkeys:<EOL><INDENT>if res[ikey].ready():<EOL><INDENT>if res[ikey].successful():<EOL><INDENT>done += <NUM_LIT:1><EOL>results = res[ikey].get(<NUM_LIT:0>)<EOL>LOGGER.info("<STR_LIT:%s>", results[<NUM_LIT:1>])<EOL>self._insert_to_array(ikey, results) <EOL>del res[ikey]<EOL><DEDENT>else:<EOL><INDENT>raise IPyradWarningExit("""<STR_LIT>""".format(res[ikey].exception()))<EOL><DEDENT><DEDENT>try:<EOL><INDENT>qidx = jobiter.next()<EOL>with h5py.File(self.database.input, '<STR_LIT:r>') as inh5:<EOL><INDENT>smps = inh5["<STR_LIT>"][qidx:qidx+self._chunksize]<EOL><DEDENT>res[qidx] = lbview.apply(nworker, *[self, smps, TESTS])<EOL><DEDENT>except StopIteration:<EOL><INDENT>continue<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>time.sleep(<NUM_LIT>)<EOL><DEDENT>elapsed = datetime.timedelta(seconds=int(time.time()-start))<EOL>if not self.checkpoint.boots:<EOL><INDENT>if not quiet:<EOL><INDENT>progressbar(njobs, done, printstr.format(elapsed), spacer="<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if not quiet:<EOL><INDENT>progressbar(self.params.nboots, self.checkpoint.boots, <EOL>printstr.format(self.checkpoint.boots, elapsed), <EOL>spacer="<STR_LIT>")<EOL><DEDENT><DEDENT>if njobs == done:<EOL><INDENT>break<EOL><DEDENT><DEDENT>self._dump_qmc()<EOL>if not self.checkpoint.boots:<EOL><INDENT>self._run_qmc(<NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>self._run_qmc(<NUM_LIT:1>)            <EOL><DEDENT>self.checkpoint.arr = <NUM_LIT:0><EOL>
Inference sends slices of jobs to the parallel engines for computing
and collects the results into the output hdf5 array as they finish.