def run(self, n_steps):
    mcstep = None
    initial_time = time.time()
    for nn in range(n_steps):
        self.step += 1
        logger.info(('Beginning MC cycle ' + str(self.step)))
        refresh = self.allow_refresh
        if ((self.step % self.status_update_frequency) == 0):
            if ((self.live_visualizer is not None) and (mcstep is not None)):
                self.live_visualizer.draw_ipynb(mcstep)
                refresh = False
            elapsed = (time.time() - initial_time)
            if (nn > 0):
                time_per_step = (elapsed / nn)
            else:
                time_per_step = 1.0
            paths.tools.refresh_output(((('Working on Monte Carlo cycle number ' + str(self.step)) + '\n') + paths.tools.progress_string(nn, n_steps, elapsed)), refresh=refresh, output_stream=self.output_stream)
        time_start = time.time()
        movepath = self._mover.move(self.sample_set, step=self.step)
        samples = movepath.results
        new_sampleset = self.sample_set.apply_samples(samples)
        time_elapsed = (time.time() - time_start)
        setattr(movepath.details, 'timing', time_elapsed)
        mcstep = MCStep(simulation=self, mccycle=self.step, previous=self.sample_set, active=new_sampleset, change=movepath)
        self._current_step = mcstep
        self.save_current_step()
        if ((self.step % self.save_frequency) == 0):
            self.sample_set.sanity_check()
            self.sync_storage()
        self.sample_set = new_sampleset
    self.sync_storage()
    if ((self.live_visualizer is not None) and (mcstep is not None)):
        self.live_visualizer.draw_ipynb(mcstep)
    paths.tools.refresh_output((('DONE! Completed ' + str(self.step)) + ' Monte Carlo cycles.\n'), refresh=False, output_stream=self.output_stream)
def run(self, n_steps):
    mcstep = None
    initial_time = time.time()
    for nn in range(n_steps):
        self.step += 1
        logger.info(('Beginning MC cycle ' + str(self.step)))
        refresh = self.allow_refresh
        if ((self.step % self.status_update_frequency) == 0):
            if ((self.live_visualizer is not None) and (mcstep is not None)):
                self.live_visualizer.draw_ipynb(mcstep)
                refresh = False
            elapsed = (time.time() - initial_time)
            if (nn > 0):
                time_per_step = (elapsed / nn)
            else:
                time_per_step = 1.0
            paths.tools.refresh_output(((('Working on Monte Carlo cycle number ' + str(self.step)) + '\n') + paths.tools.progress_string(nn, n_steps, elapsed)), refresh=refresh, output_stream=self.output_stream)
        time_start = time.time()
        movepath = self._mover.move(self.sample_set, step=self.step)
        samples = movepath.results
        new_sampleset = self.sample_set.apply_samples(samples)
        time_elapsed = (time.time() - time_start)
        setattr(movepath.details, 'timing', time_elapsed)
        mcstep = MCStep(simulation=self, mccycle=self.step, previous=self.sample_set, active=new_sampleset, change=movepath)
        self._current_step = mcstep
        self.save_current_step()
        if ((self.step % self.save_frequency) == 0):
            self.sample_set.sanity_check()
            self.sync_storage()
        self.sample_set = new_sampleset
    self.sync_storage()
    if ((self.live_visualizer is not None) and (mcstep is not None)):
        self.live_visualizer.draw_ipynb(mcstep)
    paths.tools.refresh_output((('DONE! Completed ' + str(self.step)) + ' Monte Carlo cycles.\n'), refresh=False, output_stream=self.output_stream)