def run(self, commands): self.setup_files["input.deck"] = util.decks.input_deck(solver=self.solver, num_cells_x=36, num_cells_y=74, a_x=-1.55, b_x=1.45, a_y=-1.62, b_y=1.38, t_final=1.03, sigma=1.111, init_cond = self.initcond, gaussian_sigma=self.gaussian_sigma, num_mpi_partitions_x=self.xNodes, num_mpi_partitions_y=self.yNodes) with util.ResetFile(*(self.initial_paths + self.current_paths)): util.right(self.log_path, "execution time:") util.tee(self.log_path, " " * 10, wait=True) super(RegressionTest, self).run(commands) util.tee(self.log_path, "") self.initial = util.formats.Composite(self.parser, self.initial_path, self.xNodes, self.yNodes) self.current = util.formats.Composite(self.parser, self.current_path, self.xNodes, self.yNodes) self.reference = self.parser(self.reference_path) self.show_results() return self.current
def convergence_test(target, source, env): try: util.tee(str(target[0]), "convergence tests:") for s in SOLVER: if s == "kinetic": util.bullet(str(target[0]), "%s" % s, wait=False) KineticConvergenceTest(str(target[0])).run([os.path.abspath(str(source[0]))], 5) elif s == "moment": for f in MOMENT_FILTER: util.bullet(str(target[0]), "%s(%s)" % (s, f), wait=False) MomentConvergenceTest(str(target[0]), f).run([os.path.abspath(str(source[0]))], 5) elif s == "momopt": for t in MOMOPT_TYPE: util.bullet(str(target[0]), "%s(%s)" % (s, t), wait=False) MomoptConvergenceTest(str(target[0]), t).run([os.path.abspath(str(source[0]))], 5) except: try: os.unlink(str(target[0])) except: pass raise
def regression_test(target, source, env): try: util.tee(str(target[0]), "regression tests:") for p in [str(x) for x in source]: if p.startswith("solver_mpi"): commands = [["mpirun", "-np", "4", p]] composite = True else: commands = [os.path.abspath(p)] composite = False for s in SOLVER: for i in INITCOND: if s == "kinetic": util.bullet(str(target[0]), "%s,%s,%s" % (p, s, i), wait=False) if composite: KineticCompositeRegressionTest(str(target[0]), i).run(commands) else: KineticRegressionTest(str(target[0]), i).run(commands) elif s == "moment": for f in MOMENT_FILTER: util.bullet(str(target[0]), "%s,%s,%s(%s)" % (p, s, i, f), wait=False) if composite: MomentCompositeRegressionTest(str(target[0]), f, i).run(commands) else: MomentRegressionTest(str(target[0]), f, i).run(commands) elif s == "momopt": for t in MOMOPT_TYPE: util.bullet(str(target[0]), "%s,%s,%s(%s)" % (p, s, i, t), wait=False) if composite: MomoptCompositeRegressionTest(str(target[0]), t, i).run(commands) else: MomoptRegressionTest(str(target[0]), t, i).run(commands) except: try: os.unlink(str(target[0])) except: pass raise
def run(self, commands): self.setup_files["input.deck"] = util.decks.input_deck(solver=self.solver, num_cells_x=36, num_cells_y=74, a_x=-1.55, b_x=1.45, a_y=-1.62, b_y=1.38, t_final=1.03, sigma=1.111, init_cond = self.initcond, gaussian_sigma=self.gaussian_sigma) with util.ResetFile(self.current_path, self.initial_path): util.right(self.log_path, "execution time:") util.tee(self.log_path, " " * 10, wait=True) super(RegressionTest, self).run(commands) util.tee(self.log_path, "") self.initial = self.parser(self.initial_path) self.current = self.parser(self.current_path) if REGENERATE: try: os.makedirs(os.path.dirname(self.reference_path)) except OSError: pass shutil.copyfile(self.current_path, self.reference_path) self.reference = self.parser(self.reference_path) self.show_results() return self.current
def run(self,input,**k): c = self.config cmd = '%s -l %g -u %g ' % (svm_scale_pathname, c.lower, c.upper) if c.y_lower: cmd += "-y %g %g " % (c.y_lower, c.y_upper) if k['scale info input']: cmd += '-r %s ' % k['scale info input'].pathname filename = tempfile.mktemp() sio = LibsvmScaleFile(filename,autodel=True) cmd += '-s %s ' % filename cmd += input.pathname log = self.callback.log log('# Running %s\n' % cmd) t = util.tee() util.run_command(cmd,t,log) return {'output': LibsvmInputFile(t.get_filename(),autodel=True), 'scale info output': sio}
def run(self,**k): input = k['training data'] if k['optional parameter']: self.config.__dict__.update(k['optional parameter'].get_data()) filename = tempfile.mktemp() cmd = self.make_command(input.pathname, filename) log = self.callback.log log('# Running %s\n' % cmd) t = util.tee(log) util.run_command(cmd,t,t) if self.config.fold == 0: m = LibsvmModelFile(filename,autodel=True) else: m = None # no model file while doing cv return {'stdout/stderr': TextFile(t.get_filename(), autodel=True), 'model': m }
def run(self, input, **k): c = self.config cmd = '%s -l %g -u %g ' % (svm_scale_pathname, c.lower, c.upper) if c.y_lower: cmd += "-y %g %g " % (c.y_lower, c.y_upper) if k['scale info input']: cmd += '-r %s ' % k['scale info input'].pathname filename = tempfile.mktemp() sio = LibsvmScaleFile(filename, autodel=True) cmd += '-s %s ' % filename cmd += input.pathname log = self.callback.log log('# Running %s\n' % cmd) t = util.tee() util.run_command(cmd, t, log) return { 'output': LibsvmInputFile(t.get_filename(), autodel=True), 'scale info output': sio }
def run(self, **k): input = k['training data'] if k['optional parameter']: self.config.__dict__.update(k['optional parameter'].get_data()) filename = tempfile.mktemp() cmd = self.make_command(input.pathname, filename) log = self.callback.log log('# Running %s\n' % cmd) t = util.tee(log) util.run_command(cmd, t, t) if self.config.fold == 0: m = LibsvmModelFile(filename, autodel=True) else: m = None # no model file while doing cv return { 'stdout/stderr': TextFile(t.get_filename(), autodel=True), 'model': m }
def run(self,**k): input = k['training data'] out_filename = tempfile.mktemp() png_filename = tempfile.mktemp() c = self.config cmd = "%s -svmtrain %s " % (grid_pathname, svm_train_pathname) cmd += "-gnuplot %s -out %s " % (gnuplot_pathname, out_filename) cmd += "-png %s " % png_filename cmd += "-log2c %s,%s,%s " % (c.c_begin, c.c_end, c.c_step) cmd += "-log2g %s,%s,%s " % (c.g_begin, c.g_end, c.g_step) cmd += input.pathname log = self.callback.log log('# Running %s\n' % cmd) t = util.tee(log) util.run_command(cmd,t,t) best_c, best_g, best_rate = map(float,open(t.get_filename()).readlines()[-1].split()) return {'contour': ImageFile(png_filename,autodel=True), 'result': TextFile(out_filename,autodel=True), 'stdout/stderr': TextFile(t.get_filename(),autodel=True), 'best parameter': ConfigData(cost=best_c,gamma=best_g)}