def test_unused_input(): this_path = current_path / "cwl" / "misc" / "wf-unused-input.cwl" doc = load(doc_path=this_path, type_dicts=type_dicts) assert len(doc.problems) == 1 namespace_problem = next(p for p in doc.problems if p.range.start.line == 4) assert namespace_problem.message.startswith("Unused input")
def test_implicit_inputs(): this_path = current_path / "cwl" / "misc" / "wf-when-input.cwl" doc = load(doc_path=this_path, type_dicts=type_dicts) assert len(doc.problems) == 0 cmpl = doc.completion(Position(12, 8)) assert "new_input" in [c.label for c in cmpl]
def test_docs_on_hover(): this_path = current_path / "cwl" / "misc" / "wf-when-input.cwl" doc = load(doc_path=this_path, type_dicts=type_dicts) hov = doc.hover(Position(10, 6)) assert "Sibling" in hov.contents.value assert hov.contents.kind == "markdown"
def test_definition(): doc = load(doc_path=path, type_dicts=type_dicts) linked_uri = pathlib.Path(current_path / "cwl" / "ebi" / "utils" / "concatenate.cwl") doc_def_loc = doc.definition(loc=Position(50, 20)) assert isinstance(doc_def_loc, Location) assert doc_def_loc.uri == linked_uri.as_uri()
def test_missing_name_space(): this_path = current_path / "cwl" / "misc" / "cl-missing-namespace.cwl" doc = load(doc_path=this_path, type_dicts=type_dicts) assert len(doc.problems) == 1 namespace_problem = next(p for p in doc.problems if p.range.start.line == 15) assert namespace_problem.message.startswith("Expecting one of")
def test_mass_wf_load(): type_dicts = load_type_dicts() for wf_dir in [ "ebi/workflows", "mgi/subworkflows", "mgi/pipelines", "cwl-v1.2" ]: path = current_path / "cwl" / wf_dir for fname in path.glob("*.cwl"): _ = load(doc_path=fname, type_dicts=type_dicts)
def test_plain_text_include(): this_path = current_path / "cwl" / "misc" / "cl-include-text.cwl" doc = load(doc_path=this_path, type_dicts=type_dicts) assert len(doc.problems) == 0 hov = doc.hover(Position(9, 21)) assert "We hold" in hov.contents.value
def test_requirements_completion(): this_path = current_path / "cwl" / "misc" / "cl-hints-dict.cwl" doc = load(doc_path=this_path, type_dicts=type_dicts) cmpl = doc.completion(Position(12, 8)) assert "dockerLoad" in [c.label for c in cmpl] this_path = current_path / "cwl" / "misc" / "cl-hints-list.cwl" doc = load(doc_path=this_path, type_dicts=type_dicts) cmpl = doc.completion(Position(12, 8)) assert "dockerImport" in [c.label for c in cmpl] this_path = current_path / "cwl" / "misc" / "cl-hints-dict-start.cwl" doc = load(doc_path=this_path, type_dicts=type_dicts) cmpl = doc.completion(Position(12, 5)) assert "dockerLoad" in [c.label for c in cmpl]
def test_hints_imports(): this_path = current_path / "cwl" / "misc" / "cl-hints-import.cwl" doc = load(doc_path=this_path, type_dicts=type_dicts) assert len(doc.problems) == 1 missing_error = next(p for p in doc.problems if p.range.start.line == 4) assert missing_error.message.startswith("Missing document:") cmpl = doc.completion(Position(4, 20)) assert "cl-schemadef-import.cwl" in [c.label for c in cmpl]
def test_remote_files(): this_path = current_path / "cwl" / "misc" / "wf-remote-steps.cwl" doc = load(doc_path=this_path, type_dicts=type_dicts) # Refers to an earlier commit hov = doc.hover(Position(13, 32)) assert "class:" in hov.contents.value # Non existent commit hov = doc.hover(Position(19, 32)) assert hov.contents.value == "```\n\n```"
def test_basic_JS(): path = current_path / "cwl" / "misc" / "clt1.cwl" doc = load(doc_path=path, type_dicts=type_dicts) hov = doc.hover(loc=Position(7, 25)) assert isinstance(hov.contents.value, str) assert hov.contents.value.startswith("```\nA_") hov = doc.hover(loc=Position(10, 19)) assert isinstance(hov.contents.value, str) assert "outdirSize" in hov.contents.value
def test_schemadef_include(): this_path = current_path / "cwl" / "misc" / "cl-schemadef-include.cwl" doc = load(doc_path=this_path, type_dicts=type_dicts) assert len(doc.problems) == 2 syntax_error = next(p for p in doc.problems if p.range.start.line == 12) assert syntax_error.message == "Expecting an $import" type_error = next(p for p in doc.problems if p.range.start.line == 4) assert type_error.message.startswith("Expecting one of")
def test_ebi_wf_cmsearch_multimodel(): path = current_path / "cwl" / "ebi" / "workflows" / "cmsearch-multimodel-wf.cwl" doc = load(doc_path=path, type_dicts=load_type_dicts()) step_symbols = next((symb for symb in doc.symbols if symb.name == "steps"), None) assert isinstance(step_symbols.children, list) cmsearch_symbol = next( (symb for symb in step_symbols.children if symb.name == "cmsearch"), None) assert cmsearch_symbol.range.start.line == 33
def test_port_completer(): this_path = current_path / "cwl" / "misc" / "wf-port-completer.cwl" doc = load(doc_path=this_path, type_dicts=type_dicts) cmpl = doc.completion(Position(10, 14)) # Not a list assert "in1" in [c.label for c in cmpl] cmpl = doc.completion(Position(23, 11)) # Is a list assert "out1" in [c.label for c in cmpl] cmpl = doc.completion(Position(24, 9)) # Is a list assert "in1" in [c.label for c in cmpl]
def test_v1_1_runtime(): # No exitcode in runtime in v1.0 ever path = current_path / "cwl" / "misc" / "clt1.cwl" doc = load(doc_path=path, type_dicts=type_dicts) hov = doc.hover(loc=Position(10, 19)) assert "exitCode" not in hov.contents.value hov = doc.hover(loc=Position(17, 33)) assert "exitCode" not in hov.contents.value # Exitcode in runtime in v1.1 when in output path = current_path / "cwl" / "misc" / "clt2.cwl" doc = load(doc_path=path, type_dicts=type_dicts) hov = doc.hover(loc=Position(24, 20)) assert "exitCode" not in hov.contents.value hov = doc.hover(loc=Position(31, 34)) assert "exitCode" in hov.contents.value
def __init__(self): routes = load('handler') settings = { 'static_path': os.path.join(os.path.dirname(__file__), "static"), 'template_path': os.path.join(os.path.dirname(__file__), "tpl"), 'xsrf_cookies': True, 'cookie_secret': 'tokyo', 'site_title': 'zkdash', 'ui_modules': uimodule, 'ui_methods': uimethods, 'debug': OPTIONS.debug, } tornado.web.Application.__init__(self, routes, **settings)
def __init__(self): routes = load('handler') settings = { 'static_path': os.path.join(os.path.dirname(__file__), "static"), 'template_path': os.path.join(os.path.dirname(__file__), "tpl"), 'xsrf_cookies': True, 'cookie_secret': 'tokyo', 'site_title': 'zkdash', 'ui_modules': uimodule, 'ui_methods': uimethods, 'debug': OPTIONS.debug, } tornado.web.Application.__init__(self, routes, **settings)
def test_schemadef_import(): this_path = current_path / "cwl" / "misc" / "cl-schemadef-import.cwl" doc = load(doc_path=this_path, type_dicts=type_dicts) assert len(doc.problems) == 0 cmpl = doc.completion(Position(12, 21)) assert "cl-schemadef-import.cwl" in [c.label for c in cmpl] # The completer should look for all files in the current directory cmpl = doc.completion(Position(4, 11)) assert "./paired_end_record.yml#paired_end_options" in [ c.label for c in cmpl ]
def __enter__(self): if self.dummy: return self self.lib = lib.load(os.getcwd() + "/librpicnc/build/cnc.so") c_axesinfo = (lib.AxisInfo*len(self.config["axes"]))() for i, (axis, ac) in enumerate(zip(self.config["axes"], self.cache["axes"])): c_axesinfo[i] = lib.AxisInfo(pins=axis["pins"], pos=ac["pos"], len_=ac["len"]) r = self.lib.cnc_init(len(c_axesinfo), c_axesinfo) if r != 0: raise CNCException("cnc_init error") return self
def test_connections(): path = current_path / "cwl" / "misc" / "wf-port-completer.cwl" doc = load(doc_path=path, type_dicts=load_type_dicts()) assert len(doc.problems) == 0
def test_requirement_completion(): doc = load(doc_path=path, type_dicts=type_dicts) cmpl = doc.completion(Position(8, 16)) assert "InlineJavascriptRequirement" in [c.label for c in cmpl]
def test_troublesome_tool_load(): type_dicts = load_type_dicts() path = current_path / "cwl" / "misc" for fname in path.glob("*.cwl"): _ = load(doc_path=fname, type_dicts=type_dicts)
#!-*-coding:utf-8-*- import lib import sys import numpy as np """ 3 Multiple Regression """ lib.title("#############3 Multiple Regression#############") #####データを読み取る##### CEOSAL2_dataset = lib.load(filename="CEOSAL2.csv") explanatories = ["const", "lsales", "lmktval"] explained = ["lsalary"] """ 3-1の解答 """ lib.chaper("大問3.1の回答") X = lib.df2mat(df=CEOSAL2_dataset, columns=explanatories) Y = lib.df2mat(df=CEOSAL2_dataset, columns=explained) b = lib.reg(X=X, Y=Y) lib.add_suffix(coefs=b, labels=explanatories) print("\n") """ 3-2の解答 """ lib.chaper("大問3.2の回答") CEOSAL2_dataset = lib.load(filename="CEOSAL2.csv") explanatories = ["const", "lsales", "lmktval", "profits"] explained = ["lsalary"] X = lib.df2mat(df=CEOSAL2_dataset, columns=explanatories) Y = lib.df2mat(df=CEOSAL2_dataset, columns=explained)
#!-*-coding:utf-8-*- import lib import sys import numpy as np """ 8 Instrumental Variable And 2SLS """ lib.title("#############8 Instrumental Variable And 2SLS#############") FERTIL2_dataset = lib.load( filename="FERTIL2.csv" ) FERTIL2_dataset = lib.cross_var( df=FERTIL2_dataset , var1="age" , var2="age" ) """ 8-1の解答 """ lib.chaper("<8.1の解答>") #####説明変数を定義##### explanatories = ["const","educ","age","age*age"] explained = ["children"] X = lib.df2mat( df=FERTIL2_dataset , columns=explanatories ) Y = lib.df2mat( df=FERTIL2_dataset , columns=explained ) b = lib.reg( X=X , Y=Y ) lib.add_suffix( coefs=b , labels=explanatories ) const , educ , age , age_aqure = b[0] , b[1] , b[2] , b[3] y = educ * 100 print( y ) print( "9人減る" ) print("\n")
def test_mass_tool_load(): type_dicts = load_type_dicts() for wf_dir in ["ebi/tools", "mgi/tools"]: path = current_path / "cwl" / wf_dir for fname in path.glob("*.cwl"): _ = load(doc_path=fname, type_dicts=type_dicts)
import lib import ROOT lib.load() crootprob3pp = ROOT.crootprob3pp Probability = crootprob3pp.Probability class Flavour: NU_E = 1 NU_MU = 2 NU_TAU = 3 class CP: MATTER = 1 ANTI_MATTER = -1
def test_step_input_completion(): doc = load(doc_path=path, type_dicts=type_dicts) cmpl = doc.completion(Position(37, 38)) assert "covariance_models" in [c.label for c in cmpl]
#!-*-coding:utf-8-*- import lib import sys import numpy as np """ 1 Matrix Calculus """ lib.title("#############1 Matrix Calculus#############") #####データを読み取る##### artifical_dataset = lib.load(filename="artificial.csv") explanatories = ["x1", "x2"] explained = ["y"] #####各変数を定義##### X = lib.df2mat(df=artifical_dataset, columns=explanatories) Y = lib.df2mat(df=artifical_dataset, columns=explained) b = lib.reg(X=X, Y=Y) """ 1-1の解答 """ lib.chaper("<大問1.1の回答>") #####解答##### lib.add_suffix(b) print("\n") """ 1-2の解答 """ lib.chaper("<大問1.2の回答>") #####各変数を定義#####
def test_invalid_input(): this_path = current_path / "cwl" / "misc" / "wf-invalid-input.cwl" doc = load(doc_path=this_path, type_dicts=type_dicts) assert len(doc.problems) == 1
def main(argv): # pylint: disable=W0612 try: argv = FLAGS(argv) # parse flags except gflags.FlagsError, e: print '%s\\nUsage: %s ARGS\\n%s' % (e, sys.argv[0], FLAGS) sys.exit(1) gl.set_runtime_config('GRAPHLAB_DEFAULT_NUM_GRAPH_LAMBDA_WORKERS', 16) for flag_name in sorted(FLAGS.RegisteredFlags()): if flag_name not in ["?", "help", "helpshort", "helpxml"]: fl = FLAGS.FlagDict()[flag_name] with open('output/main.out', 'a') as f: f.write( "# " + fl.help + " (" + flag_name + "): " + str(fl.value) + '\n') X_train, X_test = load(FLAGS.dataset) g = get_graph(X_train, FLAGS.rank) rmse_train, rmse_test, L, R, wu, wm, bu, bm = \ sgd_gl_edge(g, X_train, X_test, FLAGS.lamb, FLAGS.rank, FLAGS.eta, Niter=FLAGS.maxit, unified=FLAGS.unified, lambduh_w=FLAGS.lamb_w, output="main") print 'rmse_train', rmse_train print 'rmse_test', rmse_test if __name__ == '__main__': main(sys.argv) # overnightRun()
#!-*-coding:utf-8-*- import lib import sys import numpy as np """ 6 Inference2 """ lib.title("#############6 Inference2#############") #####データを読み取る##### HPRICE_dataset = lib.load(filename="HPRICE1.csv") explanatories = ["const", "sqrft", "bdrms"] explained = ["lprice"] #####各変数を定義##### X = lib.df2mat(df=HPRICE_dataset, columns=explanatories) Y = lib.df2mat(df=HPRICE_dataset, columns=explained) b = lib.reg(X=X, Y=Y) """ 6-1の解答 """ lib.chaper("<6.1の解答>") #####解答##### lib.add_suffix(b, labels=explanatories) print("\n") """ 6-2の解答 """ lib.chaper("<6.2の解答>") #####回帰係数の取得##### const, sqrft, bdrms = b[0], b[1], b[2] y_bdrms = bdrms
def test_requirement_sub_completion(): this_path = current_path / "cwl" / "ebi" / "workflows" / "InterProScan-v5-chunked-wf.cwl" doc = load(doc_path=this_path, type_dicts=type_dicts) cmpl = doc.completion(Position(8, 10)) assert "InlineJavascriptRequirement" in [c.label for c in cmpl]