def run(): # test all OK files found # Note: txt target is to test the table-to-verbatim mapping for outfile in glob.glob("ok/*"): stderr = 0 basename = re.sub('\..*?$', '', outfile.replace('ok/', '')) target = re.sub('.*\.', '', outfile) if target == 'out': target = 'txt' stderr = 1 infile = basename + ".t2t" outfile = outfile.replace('ok/', '') if lib.initTest(basename, infile, outfile): cmdline = ['-t', target] cmdline.extend(['-i', infile]) if stderr: cmdline.extend(['-o', '-']) cmdline.append('>' + outfile) cmdline.append('2>&1') lib.test(cmdline, outfile) # clean up if os.path.isfile(lib.CONFIG_FILE): os.remove(lib.CONFIG_FILE) return lib.OK, lib.FAILED, lib.ERROR_FILES
def run(): # test all OK files found # Note: txt target is to test the table-to-verbatim mapping for outfile in glob.glob("ok/*"): stderr = 0 basename = re.sub('\..*?$', '', outfile.replace('ok/', '')) target = re.sub('.*\.', '', outfile) if target == 'out': target = 'txt' stderr = 1 infile = basename + ".t2t" outfile = outfile.replace('ok/', '') if lib.initTest(basename, infile, outfile): cmdline = ['-H'] cmdline.extend(['-t', target]) cmdline.extend(['-i', infile]) if stderr: cmdline.extend(['-o', '-']) cmdline.append('>' + outfile) cmdline.append('2>&1') lib.test(cmdline, outfile) # clean up if os.path.isfile(lib.CONFIG_FILE): os.remove(lib.CONFIG_FILE) return lib.OK, lib.FAILED, lib.ERROR_FILES
def run(): # test all OK files found for outfile in glob.glob("ok/*"): stderr = 0 basename = re.sub('\..*?$', '', outfile.replace('ok/', '')) target = re.sub('.*\.', '', outfile) if target == 'out': target = 'txt' stderr = 1 infile = basename + ".t2t" outfile = outfile.replace('ok/', '') if lib.initTest(basename, infile, outfile): cmdline = ['-H'] cmdline.extend(['-t', target]) cmdline.extend(['-i', infile]) if basename in ('include-image-path', 'include-imagelink-path'): cmdline.append('--fix-path') if stderr: cmdline.extend(['-o', '-']) cmdline.append('>' + outfile) cmdline.append('2>&1') lib.test(cmdline, outfile) # clean up if os.path.isfile(lib.CONFIG_FILE): os.remove(lib.CONFIG_FILE) return lib.OK, lib.FAILED, lib.ERROR_FILES
def run(): # test all OK files found for outfile in glob.glob("ok/*"): stderr = 0 basename = re.sub('\..*?$', '', outfile.replace('ok/', '')) target = re.sub('.*\.', '', outfile) if target == 'out': target = 'txt' stderr = 1 infile = basename + ".t2t" # Using filename -H suffix to run new tests using -H option if basename.endswith('-H'): infile = basename.replace('-H', '') + ".t2t" outfile = outfile.replace('ok/', '') if lib.initTest(basename, infile, outfile): cmdline = [] cmdline = addFilters(FILTERS) if basename == 'path': cmdline.extend(['--width', '200']) if basename.endswith('-H'): cmdline.append('-H') cmdline.extend(['-o', outfile]) cmdline.extend(['-t', target]) cmdline.extend(['-i', infile]) if stderr: cmdline.extend(['-o', '-']) cmdline.append('>' + outfile) cmdline.append('2>&1') lib.test(cmdline, outfile) # clean up if os.path.isfile(lib.CONFIG_FILE): os.remove(lib.CONFIG_FILE) return lib.OK, lib.FAILED, lib.ERROR_FILES
def run(): for test in tests: infile = test["name"] + ".t2t" outfile = test["name"] + "." + (test.get("target") or "out") extra = test.get("extra") or [] cmdline = test["cmdline"] if "noinfile" not in extra: cmdline = test["cmdline"] + [infile] if lib.initTest(test["name"], infile, outfile): # create the extra files (if needed for this test) if "config" in extra: lib.WriteFile(lib.CONFIG_FILE, CONFIG_FILE_TXT) if "css" in extra: lib.WriteFile(lib.CSS_FILE, CSS_FILE_TXT) # may I add the -t target automatically? if "notarget" not in extra: cmdline = ["-t", test["target"]] + cmdline # may I redirect the output to a file? if test.get("redir"): cmdline.extend(test["redir"]) # always catch the error output cmdline.append("2>&1") # create the source file lib.WriteFile(infile, test["content"]) # convert and check results lib.test(cmdline, outfile) # remove the trash os.remove(infile) if os.path.isfile(lib.CSS_FILE): os.remove(lib.CSS_FILE) if os.path.isfile(lib.CONFIG_FILE): os.remove(lib.CONFIG_FILE)
def run(): # test all OK files found for outfile in glob.glob("ok/*"): basename = re.sub('\..*?$', '', outfile.replace('ok/', '')) infile = basename + ".t2t" if infile in remote_infiles: infile = remote_root + infile if basename in remote_mapping: infile = remote_root + remote_mapping[basename] outfile = outfile.replace('ok/', '') if lib.initTest(basename, infile, outfile): cmdline = [] cmdline.extend(['-i', infile]) if infile.startswith(remote_root) \ and basename != 'remote-outfile': cmdline.extend(['-o', outfile]) if basename == 'not-found': cmdline.append('>' + outfile) cmdline.append('2>&1') elif basename == 'stdout': cmdline.extend(['-o', '-']) cmdline.append('>' + outfile) elif basename == 'remote-outfile': cmdline.append('2>' + outfile) elif basename == 'relative-path': cmdline.extend(['-t', 'html']) cmdline.append('--fix-path') lib.test(cmdline, outfile) # clean up if os.path.isfile(lib.CONFIG_FILE): os.remove(lib.CONFIG_FILE) return lib.OK, lib.FAILED, lib.ERROR_FILES
def run(): infile = os.path.join(REPO, "samples", "sample.t2t") for target in txt2tags.TARGETS: outfile = "sample." + target cmdline = ["-t", target, "-o", outfile, infile] okfile = os.path.join(REPO, "samples", outfile) print(" ", target, end=" ") lib.test(cmdline, outfile, okfile=okfile)
def run(): # test all OK files found for outfile in glob.glob("ok/*"): basename = re.sub(r"\..*?$", "", outfile.replace("ok/", "")) target = re.sub(r".*\.", "", outfile) infile = basename + ".t2t" outfile = outfile.replace("ok/", "") if lib.initTest(basename, infile, outfile): cmdline = ["-H"] cmdline.extend(["-t", target]) cmdline.append(infile) lib.test(cmdline, outfile) # clean up if os.path.isfile(lib.CONFIG_FILE): os.remove(lib.CONFIG_FILE)
def run(): for testid in tests.split(): infile = testid + ".t2t" outfile = testid + ".html" cmdline = ["-t html -C test.conf", infile] if lib.initTest(testid, infile, outfile): # compose source file contents infile_txt = [] for letter in testid: infile_txt.append(txt[letter]) infile_txt = "\n".join(infile_txt) # create the source file lib.WriteFile(infile, infile_txt) # convert and check results lib.test(cmdline, outfile) # remove the trash os.remove(infile)
def run(): # test all OK files found for outfile in glob.glob("ok/*"): basename = re.sub('\..*?$', '', outfile.replace('ok/', '')) target = re.sub('.*\.', '', outfile) infile = basename + ".t2t" outfile = outfile.replace('ok/', '') if lib.initTest(basename, infile, outfile): cmdline = ['-H'] cmdline.extend(['-t', target]) cmdline.append(infile) lib.test(cmdline, outfile) # clean up if os.path.isfile(lib.CONFIG_FILE): os.remove(lib.CONFIG_FILE) return lib.OK, lib.FAILED, lib.ERROR_FILES
def run(): for testid in tests.split(): infile = testid + '.t2t' outfile = testid + '.html' cmdline = ['-t html --css-sugar -C test.conf', infile] if lib.initTest(testid, infile, outfile): # compose source file contents infile_txt = [] for letter in testid: infile_txt.append(txt[letter]) infile_txt = '\n'.join(infile_txt) # create the source file lib.WriteFile(infile, infile_txt) # convert and check results lib.test(cmdline, outfile) # remove the trash os.remove(infile) return lib.OK, lib.FAILED, lib.ERROR_FILES
def run(): # test all .t2t files found for infile in glob.glob("*.t2t"): basename = infile.replace(".t2t", "") outfile = basename + ".html" if lib.initTest(basename, infile, outfile): cmdline = addFilters(FILTERS.get(basename)) cmdline.append(infile) lib.test(cmdline, outfile) # using smart filters, same files generate more than one output for alias in ALIASES: infile = ALIASES[alias] + ".t2t" outfile = alias + ".html" if lib.initTest(alias, infile, outfile): cmdline = addFilters(FILTERS.get(alias)) cmdline.extend(["-o", outfile, infile]) lib.test(cmdline, outfile) # clean up if os.path.isfile(lib.CONFIG_FILE): os.remove(lib.CONFIG_FILE)
def run(): # test all .t2t files found for infile in glob.glob("*.t2t"): basename = infile.replace('.t2t', '') # Choose targets targets = all_targets if basename == 'table': targets = tableable for target in targets: outfile = basename + '.' + target testname = '%s in %s' % (basename, target) if lib.initTest(testname, infile, outfile): cmdline = [] cmdline.extend(['-i', infile]) cmdline.extend(['-t', target]) if target == 'aap': cmdline.extend(['--width', '80']) lib.test(cmdline, outfile) return lib.OK, lib.FAILED, lib.ERROR_FILES
def run(): for test in tests: target = test.get('target') or 'txt' infile = test['name'] + '.t2t' outfile = test.get('outfile') or test['name'] + '.' + target extra = test.get('extra') or [] cmdline = ['-i', infile] + test.get('cmdline', []) content = test['content'] if 'noversion' in extra: content = VERSION_GOTCHA + content if 'error' in extra: outfile = test['name'] + '.out' if lib.initTest(test['name'], infile, outfile): # create the extra files (if needed for this test) if 'config' in extra: lib.WriteFile(lib.CONFIG_FILE, CONFIG_FILE_TXT) if 'css' in extra: lib.WriteFile(lib.CSS_FILE, CSS_FILE_TXT) # may I add the -t target automatically? if not 'notarget' in extra: cmdline = ['-t', target] + cmdline # may I redirect the output to a file? if test.get('redir'): cmdline.extend(test['redir']) elif 'error' in extra: cmdline.append('> %s.out' % test['name']) # always catch the error output cmdline.append('2>&1') # create the source file lib.WriteFile(infile, EMPTY_HEADER + content + '\n' + SIMPLE_BODY) # convert and check results lib.test(cmdline, outfile) # remove the trash os.remove(infile) if os.path.isfile(lib.CSS_FILE): os.remove(lib.CSS_FILE) if os.path.isfile(lib.CONFIG_FILE): os.remove(lib.CONFIG_FILE) return lib.OK, lib.FAILED, lib.ERROR_FILES
def run(): # test all .t2t files found for infile in glob.glob("*.t2t"): basename = infile.replace('.t2t', '') outfile = basename + '.html' if lib.initTest(basename, infile, outfile): cmdline = [infile] lib.test(cmdline, outfile) # using smart filters, same files generate more than one output for alias in ALIASES.keys(): infile = ALIASES[alias] + '.t2t' outfile = alias + '.html' if lib.initTest(alias, infile, outfile): cmdline = addFilters(FILTERS.get(alias)) cmdline.append('-H') cmdline.extend(['-o', outfile, infile]) lib.test(cmdline, outfile) # clean up if os.path.isfile(lib.CONFIG_FILE): os.remove(lib.CONFIG_FILE) return lib.OK, lib.FAILED, lib.ERROR_FILES
def run(): for test in tests: infile = test['name'] + '.t2t' outfile = test['name'] + '.' + (test.get('target') or 'out') extra = test.get('extra') or [] cmdline = test['cmdline'] if not 'noinfile' in extra: cmdline = test['cmdline'] + [infile] if lib.initTest(test['name'], infile, outfile): # create the extra files (if needed for this test) if 'config' in extra: lib.WriteFile(lib.CONFIG_FILE, CONFIG_FILE_TXT) if 'css' in extra: lib.WriteFile(lib.CSS_FILE, CSS_FILE_TXT) # may I add the -t target automatically? if not 'notarget' in extra: cmdline = ['-t', test['target']] + cmdline # may I remove the SVN revision number? if 'norevision' in extra: cmdline.append(' | sed "%s;%s"' % ( SED_NO_REVISION1, SED_NO_REVISION2) ) # may I redirect the output to a file? if test.get('redir'): cmdline.extend(test['redir']) # always catch the error output cmdline.append('2>&1') # create the source file lib.WriteFile(infile, test['content']) # convert and check results lib.test(cmdline, outfile) # remove the trash os.remove(infile) if os.path.isfile(lib.CSS_FILE): os.remove(lib.CSS_FILE) if os.path.isfile(lib.CONFIG_FILE): os.remove(lib.CONFIG_FILE) return lib.OK, lib.FAILED, lib.ERROR_FILES
def run(): # test all OK files found for outfile in glob.glob("ok/*"): stderr = 0 basename = re.sub(r"\..*?$", "", outfile.replace("ok/", "")) target = re.sub(r".*\.", "", outfile) if target == "out": target = "txt" stderr = 1 infile = basename + ".t2t" outfile = outfile.replace("ok/", "") if lib.initTest(basename, infile, outfile): cmdline = ["-H"] cmdline.extend(["-t", target]) cmdline.extend(["-i", infile]) if stderr: cmdline.extend(["-o", "-"]) cmdline.append(">" + outfile) cmdline.append("2>&1") lib.test(cmdline, outfile) # clean up if os.path.isfile(lib.CONFIG_FILE): os.remove(lib.CONFIG_FILE)
def run(): ### First test the %!includeconf command errors = [ 'includeconf-itself', 'includeconf-not-found', 'includeconf-targeted', 'includeconf-text', ] unnumbered = [ 'includeconf-empty', ] # test all t2t files found for infile in glob.glob("includeconf-*.t2t"): basename = infile.replace('.t2t', '') outfile = basename + '.html' if basename in unnumbered: okfile = 'ok/not-numbered.html' else: okfile = 'ok/numbered.html' if basename in errors: outfile = basename + '.out' okfile = 'ok/' + outfile cmdline = ['-H', '-i', infile, '-o- >', outfile, '2>&1'] else: cmdline = ['-H', '-i', infile, '-o', outfile] if lib.initTest(basename, infile, outfile, okfile): lib.test(cmdline, outfile, okfile=okfile) ### Now test -C and --config-file command line options errors = ['C-not-found', 'C-text'] default_cmdline = ['-H -i body-only.t2t'] infile = 'body-only.t2t' for test in tests: # --enum-title is used by this test? if test.get('not-numbered'): okfile = 'ok/not-numbered.html' else: okfile = 'ok/numbered.html' # 1st turn (-C), 2nd turn (--config-file) for i in (1, 2): if i == 1: name = test['name'] cmdline = test['cmdline'] else: name = test['name'].replace('C', 'config-file') cmdline = map(lambda x: x.replace('-C', '--config-file'), test['cmdline']) outfile = name + '.html' if test['name'] in errors: outfile = name + '.out' okfile = 'ok/' + outfile cmdline = default_cmdline + cmdline + ['-o- >', outfile, '2>&1'] else: cmdline = default_cmdline + cmdline + ['-o', outfile] # convert and check results if lib.initTest(name, infile, outfile, okfile): lib.test(cmdline, outfile, okfile=okfile) # clean up if os.path.isfile(lib.CONFIG_FILE): os.remove(lib.CONFIG_FILE) return lib.OK, lib.FAILED, lib.ERROR_FILES
def run(): ### First test the %!includeconf command errors = [ 'includeconf-itself', 'includeconf-not-found', 'includeconf-targeted', 'includeconf-text', ] unnumbered = [ 'includeconf-empty', ] # test all t2t files found for infile in glob.glob("includeconf-*.t2t"): basename = infile.replace('.t2t', '') outfile = basename + '.html' if basename in unnumbered: okfile = 'ok/not-numbered.html' else: okfile = 'ok/numbered.html' if basename in errors: outfile = basename + '.out' okfile = 'ok/' + outfile cmdline = ['-H', '-i', infile, '-o- >', outfile, '2>&1'] else: cmdline = ['-H', '-i', infile, '-o', outfile] if lib.initTest(basename, infile, outfile, okfile): lib.test(cmdline, outfile, okfile=okfile) ### Now test -C and --config-file command line options errors = ['C-not-found', 'C-text'] default_cmdline = ['-H -i body-only.t2t'] infile = 'body-only.t2t' for test in tests: # --enum-title is used by this test? if test.get('not-numbered'): okfile = 'ok/not-numbered.html' else: okfile = 'ok/numbered.html' # 1st turn (-C), 2nd turn (--config-file) for i in (1, 2): if i == 1: name = test['name'] cmdline = test['cmdline'] else: name = test['name'].replace('C', 'config-file') cmdline = map(lambda x: x.replace('-C', '--config-file'), test['cmdline']) outfile = name + '.html' if test['name'] in errors: outfile = name + '.out' okfile = 'ok/' + outfile cmdline = default_cmdline + cmdline + [ '-o- >', outfile, '2>&1' ] else: cmdline = default_cmdline + cmdline + ['-o', outfile] # convert and check results if lib.initTest(name, infile, outfile, okfile): lib.test(cmdline, outfile, okfile=okfile) # clean up if os.path.isfile(lib.CONFIG_FILE): os.remove(lib.CONFIG_FILE) return lib.OK, lib.FAILED, lib.ERROR_FILES
super(Model, self).__init__() self.FC = torch.nn.Linear(in_features=64, out_features=10) def forward(self, x): return torch.sigmoid(self.FC(x)) if __name__ == "__main__": # 主函数入口 x, y = load_digits(return_X_y=True) train_len = int(len(x) / 10 * 7) test_len = len(x) - train_len dl = getDataLoader(x[:train_len], y[:train_len], 30, True) model = Model() model = train(model=model, dataloader=dl, EPOCH=10, loss="CEP") # PyTorch Test start = time.perf_counter() dl = getDataLoader(x[train_len:], y[train_len:], test_len, False) result1 = test(model, dl) speed1 = time.perf_counter() - start # Numpy Test start = time.perf_counter() weight_dict = DeepNumpy.getModelWeight(model) result2 = DeepNumpy.Sigmoid(DeepNumpy.Linear(x[train_len:], weight_dict['FC.weight'], weight_dict['FC.bias']))[:, 1] speed2 = time.perf_counter() - start score(y[train_len:], result1, result2, speed1, speed2)
def run(): # First test the %!includeconf command. errors = [ "includeconf-itself", "includeconf-not-found", "includeconf-targeted", "includeconf-text", ] unnumbered = ["includeconf-empty"] # Test all t2t files found. for infile in glob.glob("includeconf-*.t2t"): basename = infile.replace(".t2t", "") outfile = basename + ".html" if basename in unnumbered: okfile = "ok/not-numbered.html" else: okfile = "ok/numbered.html" if basename in errors: outfile = basename + ".out" okfile = "ok/" + outfile cmdline = ["-H", "-i", infile, "-o- >", outfile, "2>&1"] else: cmdline = ["-H", "-i", infile, "-o", outfile] if lib.initTest(basename, infile, outfile, okfile): lib.test(cmdline, outfile, okfile) # Now test -C and --config-file command line options. errors = ["C-not-found", "C-text"] default_cmdline = ["-H -i body-only.t2t"] infile = "body-only.t2t" for test in tests: # --enum-title is used by this test? if test.get("not-numbered"): okfile = "ok/not-numbered.html" else: okfile = "ok/numbered.html" # 1st turn (-C), 2nd turn (--config-file) for i in (1, 2): if i == 1: name = test["name"] cmdline = test["cmdline"] else: name = test["name"].replace("C", "config-file") cmdline = [ x.replace("-C", "--config-file") for x in test["cmdline"] ] outfile = name + ".html" if test["name"] in errors: outfile = name + ".out" okfile = "ok/" + outfile cmdline = default_cmdline + cmdline + [ "-o- >", outfile, "2>&1" ] else: cmdline = default_cmdline + cmdline + ["-o", outfile] # convert and check results if lib.initTest(name, infile, outfile, okfile): lib.test(cmdline, outfile, okfile=okfile) # clean up if os.path.isfile(lib.CONFIG_FILE): os.remove(lib.CONFIG_FILE)
#buat library pada folder lib3 def test(): print("test") #import import lib #panggil fungsi dari library lib.test()
#!/bin/sh ''''exec "$(dirname "$0")"/../ImageJ --jython "$0" "$@" # (call again with fiji)''' from ij import IJ, ImageJ import lib lib.startIJ() lib.test(lambda: IJ.run("Fiji Logo 3D")) lib.waitForWindow("ImageJ 3D Viewer") lib.quitIJ()
""" NumPy is the fundamental package for scientific computing with Python """ import lib lib.test("nihao ") # cols = (1,2,3,4,5,6,7,8,) # lib.hundredth_item(cols)