How to use _check_args method in elementium

Best Python code snippet using elementium_python

config.py

Source:config.py Github

copy

Full Screen

...192 _update_config_from_file(config, args.cfg)193 config.defrost()194 if args.opts:195 config.merge_from_list(args.opts)196 def _check_args(name):197 if hasattr(args, name) and eval(f'args.{name}'):198 return True199 return False200 # merge from specific arguments201 if _check_args('batch_size'):202 config.DATA.BATCH_SIZE = args.batch_size203 if _check_args('data_path'):204 config.DATA.DATA_PATH = args.data_path205 if _check_args('resume'):206 config.MODEL.RESUME = args.resume207 if _check_args('pretrained'):208 config.PRETRAINED = args.pretrained209 if _check_args('accumulation_steps'):210 config.TRAIN.ACCUMULATION_STEPS = args.accumulation_steps211 if _check_args('use_checkpoint'):212 config.TRAIN.USE_CHECKPOINT = True213 if _check_args('amp_opt_level'):214 config.AMP_OPT_LEVEL = args.amp_opt_level215 if _check_args('output'):216 config.OUTPUT = args.output217 if _check_args('tag'):218 config.TAG = args.tag219 if _check_args('eval'):220 config.EVAL_MODE = True221 if _check_args('throughput'):222 config.THROUGHPUT_MODE = True223 # set local rank for distributed training224 config.LOCAL_RANK = args.local_rank225 # output folder226 config.OUTPUT = os.path.join(config.OUTPUT, config.MODEL.NAME, config.TAG)227 config.freeze()228def get_config(args):229 """Get a yacs CfgNode object with default values."""230 # Return a clone so that the defaults will not be altered231 # This is for the "local variable" use pattern232 config = _C.clone()233 update_config(config, args)...

Full Screen

Full Screen

test_input.py

Source:test_input.py Github

copy

Full Screen

...11 def setUp(self):12 self.hsic_lasso = HSICLasso()13 def test_check_arg(self):14 with self.assertRaises(SyntaxError):15 self.hsic_lasso._check_args([])16 with self.assertRaises(SyntaxError):17 self.hsic_lasso._check_args([1, 2, 3])18 with self.assertRaises(ValueError):19 self.hsic_lasso._check_args(["txt"])20 with self.assertRaises(TypeError):21 self.hsic_lasso._check_args(["hoge.txt"])22 with self.assertRaises(TypeError):23 self.hsic_lasso._check_args(["hogecsv"])24 with self.assertRaises(TypeError):25 self.hsic_lasso._check_args([123])26 with self.assertRaises(TypeError):27 self.hsic_lasso._check_args([[1, 2, 3]])28 with self.assertRaises(TypeError):29 self.hsic_lasso._check_args([np.array([1, 2, 3])])30 with self.assertRaises(TypeError):31 self.hsic_lasso._check_args(["hoge", "hoge"])32 with self.assertRaises(TypeError):33 self.hsic_lasso._check_args(["hoge", [1, 2, 3]])34 with self.assertRaises(TypeError):35 self.hsic_lasso._check_args([[1, 2, 3], "hoge"])36 with self.assertRaises(TypeError):37 self.hsic_lasso._check_args(["hoge", np.array([1, 2, 3])])38 with self.assertRaises(TypeError):39 self.hsic_lasso._check_args([np.array([1, 2, 3]), "hoge"])40 with self.assertRaises(TypeError):41 self.hsic_lasso._check_args([123, [1, 2, 3]])42 with self.assertRaises(TypeError):43 self.hsic_lasso._check_args([[1, 2, 3], 123])44 with self.assertRaises(TypeError):45 self.hsic_lasso._check_args([123, np.array([1, 2, 3])])46 with self.assertRaises(TypeError):47 self.hsic_lasso._check_args([np.array([1, 2, 3]), 123])48 with self.assertRaises(TypeError):49 self.hsic_lasso._check_args([[1, 2, 3], np.array([1, 2, 3])])50 with self.assertRaises(TypeError):51 self.hsic_lasso._check_args([np.array([1, 2, 3]), [1, 2, 3]])52 self.assertTrue(self.hsic_lasso._check_args(["hoge.csv"]))53 self.assertTrue(self.hsic_lasso._check_args(["hoge.tsv"]))54 self.assertTrue(self.hsic_lasso._check_args(["hoge.mat"]))55 self.assertTrue(self.hsic_lasso._check_args([np.array([1, 2, 3]),56 np.array([1, 2, 3])]))57 self.assertTrue(self.hsic_lasso._check_args([[1, 2, 3], [1, 2, 3]]))58 def test_input_data_file(self):59 self.assertTrue("./tests/test_data/csv_data.csv")60 self.assertTrue("./tests/test_data/tsv_data.tsv")61 self.assertTrue("./tests/test_data/mat_data.mat")62 def test_input_data_list(self):63 self.hsic_lasso._input_data_list([[1, 1, 1],64 [2, 2, 2]65 ],66 [1, 2])67 X_in_row, X_in_col = self.hsic_lasso.X_in.shape68 Y_in_row, Y_in_col = self.hsic_lasso.Y_in.shape69 self.assertEqual(X_in_row, 3)70 self.assertEqual(X_in_col, 2)71 self.assertEqual(Y_in_row, 1)...

Full Screen

Full Screen

funcs.py

Source:funcs.py Github

copy

Full Screen

...5 def __init__(self, fname, args_list, ip):6 self.fname = fname7 self.args_list = args_list8 self.ip = ip9def _check_args(fname, args_count, args, types):10 if len(args) < args_count:11 raise Exception("Function(%s) too few arguments!" % fname)12 elif len(args) > args_count:13 raise Exception("Function(%s) too many arguments!" % fname)14 for i in range(len(args)):15 if not isinstance(args[i], types[i]):16 raise Exception("Function(%s) argument(%d) type is error!" % (fname, i))17def _check_vargs(fname, args, t):18 for i in range(len(args)):19 if not isinstance(args[i], t):20 raise Exception("Function(%s) argument(%d) type is error!" % (fname, i))21def _check_args_mt(fname, args_count, args, types):22 if len(args) < args_count:23 raise Exception("Function(%s) too few arguments!" % fname)24 elif len(args) > args_count:25 raise Exception("Function(%s) too many arguments!" % fname)26 for i in range(len(args)):27 match_type = False28 for t in types[i]:29 if isinstance(args[i], t):30 match_type = True31 break32 if not match_type:33 raise Exception("Function(%s) argument(%d) type is error!" % (fname, i))34def func_add(args):35 _check_args("+", 2, args, (float, float))36 return args[0] + args[1]37def func_sub(args):38 _check_args("-", 2, args, (float, float))39 return args[0] - args[1]40def func_mul(args):41 _check_args("*", 2, args, (float, float))42 return args[0] * args[1]43def func_div(args):44 _check_args("/", 2, args, (float, float))45 return args[0] / args[1]46def func_pow(args):47 _check_args("^", 2, args, (float, float))48 return args[0] ** args[1]49def func_mod(args):50 _check_args("%", 2, args, (float, float))51 return args[0] % args[1]52def func_neq(args):53 _check_args_mt("!=", 2, args, ((float, str, unicode), (float, str, unicode)))54 return args[0] != args[1]55def func_eq(args):56 _check_args_mt("=", 2, args, ((float, str, unicode), (float, str, unicode)))57 return args[0] == args[1]58def func_gt(args):59 _check_args_mt(">", 2, args, ((float, str, unicode), (float, str, unicode)))60 return args[0] > args[1]61def func_lt(args):62 _check_args_mt("<", 2, args, ((float, str, unicode), (float, str, unicode)))63 return args[0] < args[1]64def func_ge(args):65 _check_args_mt(">=", 2, args, ((float, str, unicode), (float, str, unicode)))66 return args[0] >= args[1]67def func_le(args):68 _check_args_mt("<=", 2, args, ((float, str, unicode), (float, str, unicode)))69 return args[0] <= args[1]70def func_input(args):71 _check_args("input", 0, args, ())72 return str(input())73def func_print(args):74 for item in args:75 sys.stdout.write(unicode(item))76 sys.stdout.flush()77 return None78def func_sum(args):79 _check_vargs("sum", args, float)80 total = 0.081 for item in args:82 total = total + float(item)83 return total84def func_run(args):85 _check_args("run", 1, args, (core.InsPtr,))86 return core.run(args[0].code, args[0].ip)[0]87def func_exec(args):88 _check_vargs("exec", args, core.InsPtr)89 r = 0.090 for item in args:91 r = core.run(item.code, item.ip)[0]92 return r93def func_if(args):94 if len(args) == 2:95 _check_args("if", 2, args, (bool, core.InsPtr))96 if args[0]:97 return core.run(args[1].code, args[1].ip)[0]98 elif len(args) == 3:99 _check_args("if", 3, args, (bool, core.InsPtr, core.InsPtr))100 if args[0]:101 return core.run(args[1].code, args[1].ip)[0]102 else:103 return core.run(args[2].code, args[2].ip)[0]104 else:105 raise Exception("Invalid if")106def func_str(args):107 if(len(args) != 1):108 raise Exception("Invalid str")109 return str(args[0])110def func_float(args):111 if(len(args) != 1):112 raise Exception("Invalid float")113 return float(args[0])114def func_symbol(args):115 _check_args("symbol", 2, args, (core.InsPtr, float))116 return args[0].code[args[0].ip + int(args[1])]117def func_define(args):118 _check_args_mt("define", 2, args, ((core.Symbol,), (float, str, unicode)))119 core.define(args[0].symbol, args[1])120 return None121def func_set(args):122 _check_args_mt("set", 2, args, ((core.Symbol,), (float, str, unicode)))123 core.set_var(args[0].symbol, args[1])124 return None125def func_defun(args):126 if len(args) < 2 or not isinstance(args[0], core.Symbol):127 raise Exception("Expect function name")128 fname = args[0].symbol129 args_list = []130 i = 1131 while i < len(args):132 if isinstance(args[i], core.Symbol):133 args_list.append(args[i].symbol)134 else:135 break136 i = i + 1137 if i != len(args) - 1 or not isinstance(args[i], core.InsPtr):138 raise Exception("Invalid function definition")139 funcs[fname] = UserFunc(fname, args_list, args[i])140 return None141def func_v(args):142 _check_args_mt("v", 1, args, ((float, str, unicode, core.InsPtr),))143 return args[0]144def func_error(args):145 _check_args_mt("error", 1, args, ((str, unicode),))146 raise Exception(args[0])147def func_next(args):148 _check_args("next", 1, args, (core.InsPtr,))149 if args[0].ip + 1 >= len(args[0].code):150 raise Exception("Out of range")151 args[0].ip = args[0].ip + 1152 return args[0].code[args[0].ip - 1]153def func_prev(args):154 _check_args("prev", 1, args, (core.InsPtr,))155 if args[0].ip - 1 < 0:156 raise Exception("Out of range")157 args[0].ip = args[0].ip - 1158 return args[0].code[args[0].ip + 1]159def func_eos(args):160 _check_args("eos", 1, args, (core.InsPtr,))161 return args[0].ip >= len(args[0].code)162def init():163 funcs["+"] = func_add164 funcs["-"] = func_sub165 funcs["*"] = func_mul166 funcs["/"] = func_div167 funcs["^"] = func_pow168 funcs["%"] = func_mod169 funcs["!="] = func_neq170 funcs["="] = func_eq171 funcs[">"] = func_gt172 funcs["<"] = func_lt173 funcs[">="] = func_ge174 funcs["<="] = func_le...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run elementium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful