def __main__(): m = 1000 perc = [ 10, 20, 30, 40, 50, 60, 70, 75, 80, 85, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100 ] lista = {'m': m, 'perc': perc} pickle.dump(lista, open("in.p", "wb")) lista = pickle.load(open("in.p", "rb")) test.run(lista) res = pickle.load(open("res.txt", "rb")) y = [] z = [] res1 = res['Concatenata'] res2 = res['IndirAperto'] x = lista['perc'] for i in range(0, len(x)): y.append(res1[str(x[i]) + "%"][1]) z.append(res2[str(x[i]) + "%"][1]) plt.xlabel('Percentuale') plt.ylabel('N Collisioni') plt.title('Hash Concatenato - Indirizzamento Aperto') plt.plot(x, y, 'b') plt.plot(x, z, 'g') plt.show()
def run_case(rootdir, nx, ndrifters): ## Make grid ## print 'Making grid for %s' % rootdir shp = (3, 29, nx) grdshp = (shp[1]+3, shp[2]+3) make_grd(rootdir, Hmin=100.0, alpha=0.0, f=0, dx=3e3, dy=3e3, shp=grdshp) ## Make synthetic velocity fields ## print 'Making model output...' make_uv.make(rootdir) ## Run TracPy ## print 'Running TracPy...' test.run(rootdir, ndrifters) ## Remove simulation run files to save space ## print 'Deleting ocean simulation files...' outputloc = os.path.join(rootdir, 'ocean_his_0001.nc') os.system('rm ' + outputloc)
def main(argv): """ """ parser = OptionParser("usage: %prog [options] testname") parser.add_option("--tb", dest="tbname", default="ion_core", help="use RTL testbench NAME", metavar="NAME") parser.add_option("--regression", dest="regression", default=None, help="execute regression list in FILE", metavar="FILE") parser.add_option("-q", "--quiet", action="store_true", dest="quiet", default=False, help="don't print build and simulation output to console") parser.add_option("-n", "--noexitcode", action="store_false", dest="check_exit", default=True, help="don't check test program exit code") parser.add_option("-r", "--rtl", action="store_true", dest="only_rtl", default=False, help="run only RTL simulation") parser.add_option("-s", "--sw", action="store_true", dest="only_sw", default=False, help="run only software simulation") (opts, args) = parser.parse_args() if not opts.regression and len(args) != 1: print >> sys.stderr, "Error: Must specify a test name or a regression list file.\n" parser.print_help() sys.exit(1) test.run(opts.tbname, args[0], hw=not opts.only_sw, sw=not opts.only_rtl, quiet=opts.quiet, check_output=opts.check_exit)
def run(self, *args, **kwargs): if self.distribution.install_requires: self.distribution.fetch_build_eggs(self.\ distribution.install_requires) if self.distribution.tests_require: self.distribution.fetch_build_eggs(self.distribution.tests_require) from test import run run()
def test(run_mpi_tests, verbose_ctest, examples_build_dir, build_examples): import test if not examples_build_dir: examples_build_dir = os.path.join(buildinfo.binary_dir, 'examples_build') test.run(run_mpi_tests, verbose_ctest) if build_examples: test.compile_examples(examples_build_dir)
def main(_): FLAGS = tf.app.flags.FLAGS pp = pprint.PrettyPrinter() FLAGS._parse_flags() pp.pprint(FLAGS.__flags) # Load embedding emb_matrix, char2id, id2char = Helper.get_embedding(FLAGS.embedding_path) print "Load embedding" # Directly load data into list train_data_list = Helper.read_json_file(FLAGS.train_json_path) print 'Train data num:', len(train_data_list) test_data_list = Helper.read_json_file(FLAGS.test_json_path) # test_data_list =None # Create model storage directories if not os.path.exists(FLAGS.ckpt_dir): os.makedirs(FLAGS.ckpt_dir) timestamp = datetime.now().strftime('%c') FLAGS.log_dir = os.path.join(FLAGS.log_dir, timestamp) if not os.path.exists(FLAGS.log_dir): os.makedirs(FLAGS.log_dir) # Gpu number os.environ["CUDA_VISIBLE_DEVICES"] = FLAGS.gpu config = tf.ConfigProto() config.gpu_options.allow_growth = True # Train Model with tf.Session(config=config) as sess: model = SeaReader(FLAGS.doc_max_len, FLAGS.top_n, FLAGS.statement_max_len, FLAGS.hidden_dim, FLAGS.answer_num, FLAGS.embedding_dim, emb_matrix, FLAGS.learning_rate, sess) saver = tf.train.Saver(max_to_keep=50) # Run evaluation if FLAGS.evaluate: print '[?] Test run' if not FLAGS.restore_file: print('Need to specify a restore_file checkpoint to evaluate') else: print('[?] Loading variables from checkpoint %s' % FLAGS.restore_file) saver.restore(sess, FLAGS.restore_file) test.run(FLAGS, sess, model, test_data_list, char2id) elif FLAGS.debug_run: print '[?] Debug run' train.debug_run(FLAGS, sess, model, train_data_list, test_data_list, char2id, saver) else: print '[?] Run' train.run(FLAGS, sess, model, train_data_list, test_data_list, char2id, saver)
def wave(methodcnt): # NOTE - INSTANTIATE WITH SPECIAL CASE """global setup_bool # initial bootup if (setup_bool == False or methodcnt == False): setup_bool = True else:""" print("waving") test.run('h', 1) # react_with_sound(confirmation_final) return 0
def run_tests(tests, verbose, continue_failure, control): for test in test_generator(tests, util.get_arches(), verbose): try: test.config() test.build(force_build=False) test.run(control=control) except Exception as e: handle_failure(test, e) if not continue_failure: break
def init(arg): tests = [] for i in os.listdir("test/tests"): if i != "__init__.py" and i[-3:] == ".py": tests.append(i.split(".")[0]) if arg[1] in tests: test.run(arg[1]) else: print("Options are: {}".format(tests))
def main(_): FLAGS = tf.app.flags.FLAGS pp = pprint.PrettyPrinter() FLAGS._parse_flags() pp.pprint(FLAGS.__flags) # Load Data X_train, Q_train, Y_train = data_helper.load_data('train') X_test, Q_test, Y_test = data_helper.load_data('valid') vocab_size = np.max(X_train) + 1 print('[?] Vocabulary Size:', vocab_size) # Create directories if not os.path.exists(FLAGS.ckpt_dir): os.makedirs(FLAGS.ckpt_dir) timestamp = datetime.now().strftime('%c') FLAGS.log_dir = os.path.join(FLAGS.log_dir, timestamp) if not os.path.exists(FLAGS.log_dir): os.makedirs(FLAGS.log_dir) # Train Model with tf.Session(config=tf.ConfigProto( log_device_placement=False, allow_soft_placement=True)) as sess, tf.device('/gpu:0'): model = AlternatingAttention(FLAGS.batch_size, vocab_size, FLAGS.encoding_dim, FLAGS.embedding_dim, FLAGS.num_glimpses, session=sess) if FLAGS.trace: # Trace model for debugging train.trace(FLAGS, sess, model, (X_train, Q_train, Y_train)) return saver = tf.train.Saver() if FLAGS.restore_file is not None: print('[?] Loading variables from checkpoint %s' % FLAGS.restore_file) saver.restore(sess, FLAGS.restore_file) # Run evaluation if FLAGS.evaluate: if not FLAGS.restore_file: print('Need to specify a restore_file checkpoint to evaluate') else: test_data = data_helper.load_data('test') word2idx, _, _ = data_helper.build_vocab() test.run(FLAGS, sess, model, test_data, word2idx) else: train.run(FLAGS, sess, model, (X_train, Q_train, Y_train), (X_test, Q_test, Y_test), saver)
def test(run_mpi_tests, perftests_only, verbose_ctest, examples_build_dir, build_examples): import test if perftests_only: test.run_perftests() else: test.run(run_mpi_tests, verbose_ctest) if build_examples: test.compile_and_run_examples(examples_build_dir, verbose_ctest)
def run_test(self): print(sil_list) test.run(file, sil_list, snd_list, th_list) self.par_label['text'] = 'Done! Click on View results\n' self.pb.step(347.9999) self.seg_btn.configure(bg="#fff1c1", activebackground="#fcfbdd", fg="#216583", activeforeground="#0880af") self.res_btn.configure(bg="#216583", activebackground="#0880af", fg="white", activeforeground="white")
def main(_): FLAGS = tf.app.flags.FLAGS pp = pprint.PrettyPrinter() FLAGS._parse_flags() pp.pprint(FLAGS.__flags) # Load Data X_train, Q_train, Y_train = data_helper.load_data('train') X_test, Q_test, Y_test = data_helper.load_data('valid') vocab_size = np.max(X_train) + 1 print('[?] Vocabulary Size:', vocab_size) # Create directories if not os.path.exists(FLAGS.ckpt_dir): os.makedirs(FLAGS.ckpt_dir) timestamp = datetime.now().strftime('%c') FLAGS.log_dir = os.path.join(FLAGS.log_dir, timestamp) if not os.path.exists(FLAGS.log_dir): os.makedirs(FLAGS.log_dir) # Train Model with tf.Session(config=tf.ConfigProto(log_device_placement=False, allow_soft_placement=True)) as sess, tf.device('/gpu:0'): model = AlternatingAttention(FLAGS.batch_size, vocab_size, FLAGS.encoding_dim, FLAGS.embedding_dim, FLAGS.num_glimpses, session=sess) if FLAGS.trace: # Trace model for debugging train.trace(FLAGS, sess, model, (X_train, Q_train, Y_train)) return saver = tf.train.Saver() if FLAGS.restore_file is not None: print('[?] Loading variables from checkpoint %s' % FLAGS.restore_file) saver.restore(sess, FLAGS.restore_file) # Run evaluation if FLAGS.evaluate: if not FLAGS.restore_file: print('Need to specify a restore_file checkpoint to evaluate') else: test_data = data_helper.load_data('test') word2idx, _, _ = data_helper.build_vocab() test.run(FLAGS, sess, model, test_data, word2idx) else: train.run(FLAGS, sess, model, (X_train, Q_train, Y_train), (X_test, Q_test, Y_test), saver)
def test_08(): o, e = run(''' function : void f() { int i; if (true) {return; } }''') return 'success' in o
def test_11(): o, e = run(''' function : void f() { int i; int * pi = &i; }''') return 'success' in o
def test_12(): o, e = run(''' function : void f() { float[5] f; float * fp = f; }''') return 'success' in o
def test_13(): o, e = run(''' function : void f() { float * fp; int * ip = fp; }''') return 'Initialization value of type float* not assignable to constant/variable of type int*.' in o
def test_07(): o, e = run(''' function : bool f() { int* pi; return NULL != pi; }''') return 'success' in o
def test_01(): o,e = run(''' function : void f() { int * pi; new pi; }''') return 'success' in o
def test_06(): o, e = run(''' function : bool f() { int* pi; return pi != NULL; }''') return 'success' in o
def test_15(): o, e = run(''' function : void f() { bool * pb; pb--; }''') return 'success' in o
def test_14(): o, e = run(''' function : void f() { bool * pb; --pb; }''') return 'success' in o
def test_01(): o, e = run(''' function : bool f () { int * pia, pib; return pia == pib; }''') return 'success' in o
def test_09(): o,e = run(''' typedef bool B; const B b= true; int[b] ia; ''') return 'Index expression type (B) in array declaration not equivalent to int.' in o
def test_05(): o,e = run(''' function : void f() { float[5] fa; new fa; }''') return "Type of new's operand must be of pointer type, float[5] found."
def test_02(): o, e = run(''' int i, j; function : void f() { i.j = 5; }''') return 'Type of expression referenced by "." (int) is not a struct.' in o
def test_01(): o,e = run(''' function : void f(int i) { } function : void m() { f((int)3.1415); }''') return 'success' in o
def test_03(): o, e = run(''' function : void m() { int i; int j = *i; }''') return 'Incompatible type int to unary dereference operator *, pointer expected.' in o
def test_06(): o, e = run(''' structdef S { int i; }; S s; int i = s->i; ''') return 'Incompatible type S to operator ->, pointer to struct expected.' in o
def test_04a(): o,e = run(''' typedef int I; function : int f(int i) { return 42; } int i = f((I)true); ''') return 'success' in o
def test_05(): o,e = run(''' typedef int I; const I i = 42; float[i] fa; ''') return 'success' in o
def run_model(filename): """Runs the pretrained COCO model""" # TODO check to see if this goes any faster with GPUS enabled... # TODO make is it so that concurrent users won't mess with eachother :P aka have hashed or something dataset routes... # that will also take a lot of cleaning up... # TODO figure out how to not do this from the command line... return run(verbose=verbose)
def test_20(): o,e = run(''' typedef float** FPP; const int i = 27; const int j = (int)(FPP) i; ''') return 'success' in o and '<CVar><value><IntValue>27</IntValue></value><name>j</name></CVar>' in e
def scence1(screen): #background = gameObject.createBgd(tileSheet) screen.fill((0,0,0)) zeldaDialog = Dialog(screen, zeldaPhoto) linkDialog = Dialog(screen, linkPhoto) unNoDialog = Dialog(screen) unNoDialog.message = ( "???: Excuse me! Sir. ", "Princess Zelda would like to have a word with you. ", "She is waiting for you in front of the castle. ", "Do not make princess waiting for you to long. ",) unNoDialog.show = True unNoDialog.sndNext() unNoDialog.message = ( "Ok, let me explain the basic control. ", "Basicly, there are three keyboard you have to know: ", "Escape key: exit from current state (useless in dialog) ", "Spacebar : to advance dialog, to talk, to start the game ", "Enter key : mostly work the same as spacebar ", "use arrow key to move. ") unNoDialog.show = True unNoDialog.sndNext() linkDialog.message = ( "Ok! I will be there right away. ", "Thank you. ") linkDialog.show = True linkDialog.sndNext() if test.run(screen): keepGoing = True else: keepGoing = False return True #donePlayer = True cover = pygame.Surface(screen.get_size()) cover.fill((0,0,0,0)) cover = cover.convert() alpha = 0 time = pygame.time.Clock() pygame.mixer.music.fadeout(500) while keepGoing: time.tick(30) if alpha >= 255: keepGoing = False cover.set_alpha(alpha) alpha += 5 screen.blit(cover, (0,0)) pygame.display.flip() return False #donePlaying = false
def runtests(tests, args): for t in tests: tid = test.id(t) if not tid: continue try: targs = list(args) if test.run(t, tid, targs): print("OK : "+test.info(t)+" ["+tid+"]"); else: print("FAIL : "+test.info(t)+" ["+tid+"]"); except: print("EXCEPTION while running test with ID: "+tid); raise return 1 return 0
if exists path "...": log ERROR No2 else: log TRACE Yes if exists directory "..": log TRACE Yes else: log ERROR No3 if exists directory "README": log ERROR No4 else: log TRACE Yes if exists file "README": log TRACE Yes else: log ERROR No5 if exists file "..": log ERROR No6 else: log TRACE Yes shutdown """ main_words.register_statement(ShutdownHandler) load_module("logging") load_module("ifelse") load_module("path") load_module("block") run("path",input)
list fs20 tx list fs20 tx tempix list fs20 tx hygrix async: wait: for 0.1 debug force del fs20 receiver foobar wait: for 0.1 debug force del fs20 sender bar foo wait: for 0.7 debug force list fs20 receiver list fs20 sender shutdown """ main_words.register_statement(ShutdownHandler) main_words.register_statement(Load) load_module("block") load_module("file") load_module("data") load_module("ifelse") load_module("path") run("fs20", input)
name="for" doc="for you!" class WhatHandler(sbr,ComplexStatement): name="what" doc="What is this?" class FoiledHandler(sbr,Statement): name="foiled" doc="not clingfilm" BarHandler.register_statement(WhatHandler) BarHandler.register_statement(ForHandler) ForHandler.register_statement(FoiledHandler) main_words.register_statement(FooHandler) main_words.register_statement(BarHandler) main_words.register_statement(ShutdownHandler) load_module("help") class TestInterpreter(Interpreter): def complex_statement(self,args): fn = self.ctx.words.lookup(args) fn = fn(self.ctx) fn.called(args) fn.start_block() return TestInterpreter(ctx=self.ctx(words=fn)) def done(self): log(None,"... moving up") run("parser", input, interpreter=TestInterpreter, logger=log)
- - # make symlinks for test data - if build_cmd.build_lib != top_dir: - for path in ['testfiles.tar.gz', 'testtar.tar', 'gnupg']: - src = os.path.join(top_dir, 'testing', path) - target = os.path.join(build_cmd.build_lib, 'testing', path) - try: - os.symlink(src, target) - except Exception: - pass - - os.environ['PATH'] = "%s:%s" % ( - os.path.abspath(build_scripts_cmd.build_dir), - os.environ.get('PATH')) - - test.run(self) - - class InstallCommand(install): def run(self): - # Normally, install will call build(). But we want to delete the - # testing dir between building and installing. So we manually build - # and mark ourselves to skip building when we run() for real. - self.run_command('build') - self.skip_build = True - - # This should always be true, but just to make sure! - if self.build_lib != top_dir: - testing_dir = os.path.join(self.build_lib, 'testing') - os.system("rm -rf %s" % testing_dir) -
## GNU General Public License (included; see the file LICENSE) ## for more details. ## ## This header is auto-generated and may self-destruct at any time, ## courtesy of "make update". The original is in ‘scripts/_boilerplate.py’. ## Thus, do not remove the next line, or insert any blank lines above. ##BP from moat import patch;patch() from moat.reactor import ShutdownHandler from moat.module import load_module from moat.statement import main_words from test import run input = """\ trigger foo :sync wait: for 1m -90s 0.5min +.5s trigger bar :sync trigger baz notlogged : log NONE sync shutdown """ main_words.register_statement(ShutdownHandler) load_module("trigger") load_module("wait") run("trigger",input)
#!/usr/bin/python script = r""" MD Dir1 MD Dir1\Dir2 MF Dir1\readme.txt MDL c:\dir1\readme.txt dir1\dir2 MD Dir3 COPY dir1\dir2 Dir3 DEL dir1\readme.txt """ expected = r""" C: |_DIR1 | |_DIR2 | |_DIR3 |_DIR2 """ import test test.run(script, expected)
wait: for 1.1 set rrd 10 t tt ttt wait: for 1.1 set rrd 11 t tt ttt wait: for 1.1 set rrd 12 t tt ttt list rrd t tt ttt block: var rrd x last_ds t tt ttt trigger last $x del rrd t tt ttt block: if exists rrd t tt ttt: log ERROR No3 else: log TRACE Yes """ main_words.register_statement(ShutdownHandler) load_module("trigger") load_module("ifelse") load_module("data") load_module("rrd") load_module("logging") load_module("block") load_module("wait") run("rrd",input)
def run_tests(self): import test errno = test.run() sys.exit(errno)
log DEBUG now we test a port that does not answer async: connect wago localhost 59068: name test no_answer retry 0.12 0.5 #ping 1 wait poll no_answer: for 1 debug force list wago server test no_answer del wago server test no_answer wait poll end: for 2 shutdown """ main_words.register_statement(DoNothingHandler) main_words.register_statement(ShutdownHandler) main_words.register_statement(Load) load_module("block") load_module("file") load_module("ifelse") load_module("path") load_module("data") run("wago",input)
## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License (included; see the file LICENSE) ## for more details. ## ## This header is auto-generated and may self-destruct at any time, ## courtesy of "make update". The original is in ‘scripts/_boilerplate.py’. ## Thus, do not remove the next line, or insert any blank lines above. ##BP from moat.reactor import ShutdownHandler from moat.module import Load,load_module from moat.statement import main_words from test import run input = """\ load example """+("# This is a filler to test processing of really long files.\n"*10000)+"""\ del module example shutdown """ main_words.register_statement(ShutdownHandler) main_words.register_statement(Load) load_module("data") run("modules",input)
for 0.6 debug force # moat => amqp # translate hey.x to amqte.x shutdown """.format(host) main_words.register_statement(ShutdownHandler) main_words.register_statement(Load) load_module("amqp") load_module("wait") load_module("logging") load_module("on_event") load_module("net") load_module("data") load_module("block") load_module("state") load_module("errors") load_module("trigger") load_module("ifelse") load_module("bool") load_module("help") run("amqp",input) import sys sys.exit(0)
try: wait shutdown: for 5 debug force wait foo b: for 1 debug force shutdown """ main_words.register_statement(ShutdownHandler) main_words.register_statement(Load) load_module("wait") load_module("logging") load_module("on_event") load_module("net") load_module("data") load_module("block") load_module("rpc") load_module("state") load_module("errors") load_module("trigger") run("rpc", input) import sys sys.exit(0)
log TRACE Yes else: log ERROR No $one block: wait foo waiter: for 0.3 wait vorher: for 0.1 trigger foo: param one two param three 4 wait nachher: for 0.1 list wait list wait foo waiter wait ende: for 0.3 shutdown """ main_words.register_statement(ShutdownHandler) load_module("trigger") load_module("wait") load_module("logging") load_module("ifelse") load_module("bool") load_module("block") load_module("data") load_module("on_event") run("data",input)
trigger baz dud $vav trigger baz: param quux $vav wait :for 0.1 block: var state va dud if equal $va "nix": log TRACE Yes else: log ERROR handler not called trigger num "1" trigger num 2 trigger num 3 shutdown """ main_words.register_statement(DoNothingHandler) main_words.register_statement(ShutdownHandler) load_module("block") load_module("trigger") load_module("on_event") load_module("ifelse") load_module("bool") load_module("data") load_module("logging") load_module("state") load_module("wait") run("on",input)
block: if last state two foo bar: log TRACE "Yes!" else: log TRACE "No‽ 6" on whatever: var state x foo bar log TRACE We got $x log DEBUG End1 trigger whatever :sync log DEBUG End2 list state log DEBUG End3 shutdown log DEBUG End4 """ main_words.register_statement(ShutdownHandler) load_module("state") load_module("block") load_module("data") load_module("on_event") load_module("logging") load_module("ifelse") load_module("bool") load_module("trigger") load_module("errors") run("persist1",input)
log DEBUG Y what $what else: log ERROR N what $what list on trigger run test: param also two sync wait :for 0.1 list on trigger test me wait :for 60 shutdown """ main_words.register_statement(DoNothingHandler) main_words.register_statement(ShutdownHandler) load_module("block") load_module("trigger") load_module("on_event") load_module("exec") load_module("ifelse") load_module("bool") load_module("data") load_module("logging") load_module("state") load_module("wait") load_module("amqp") run("exec",input)
import test test.run()
log TRACE ending list net connection block: if exists net connection foo: list net connection foo del net connection foo log DEBUG No2 else: log DEBUG Yes wait END: for 0.2 shutdown """ main_words.register_statement(ShutdownHandler) main_words.register_statement(Load) load_module("wait") load_module("logging") load_module("on_event") load_module("net") load_module("data") load_module("block") load_module("ifelse") run("net",input) import sys sys.exit(0)
name moni test wait :for 0.1 set output 2 monitest wait :for 0.2 set output 3 monitest wait :for 0.2 set output 4 monitest wait :for 0.2 set output 5 monitest list monitor list monitor moni test del monitor moni test shutdown """ main_words.register_statement(ShutdownHandler) load_module("trigger") load_module("monitor") load_module("block") load_module("data") load_module("logging") load_module("wait") load_module("tests") load_module("ifelse") load_module("bool") load_module("on_event") run("monitor",input)
trigger foo1 trigger bar1 wait A: for 0.1 trigger foo2 :sync trigger bar2 :sync wait B: for 0.1 skip this: trigger never the same block: trigger foo3 trigger bar3 wait C: for 0.1 block: if exists file "misc2": include "misc2" else: include "test/misc2" shutdown """ main_words.register_statement(ShutdownHandler) load_module("trigger") load_module("wait") load_module("block") load_module("path") load_module("file") load_module("ifelse") run("misc",input)
def main(): import test test.run(get_daily_specials)
set output four foo bar log ERROR No four catch: log TRACE Yes set output GRMPF foo bar block: var input bla foo bar if equal $bla "TEST": log ERROR No $bla else: log TRACE Yes list input foo bar list output foo bar shutdown """ main_words.register_statement(ShutdownHandler) load_module("ifelse") load_module("data") load_module("block") load_module("bool") load_module("logging") load_module("tests") load_module("errors") run("io",input)