How to use replace_val method in localstack

Best Python code snippet using localstack_python

MDP_Builder.py

Source:MDP_Builder.py Github

copy

Full Screen

...44 except KeyError:45 pass46 def replace_key(self, original, new):47 self.to_write = OrderedDict([(new, v) if k == original else (k, v) for k, v in self.to_write.items()])48 def replace_val(self, key, new_val):49 new_val = str(new_val) + " "50 self.to_write[key] = new_val51 if key == "tc-grps":52 ngrps = len(new_val.split())53 self.to_write["tau_t"] *= ngrps54 self.to_write["ref_t"] *= ngrps55 def replace_key_val(self, ori_key, new_key, new_val):56 self.to_write = OrderedDict([(new_key, new_val) if k == ori_key else (k, v) for k, v in self.to_write.items()])57 def add_key(self, key, val):58 self.to_write[key] = val59 def add_is(self):60 self.combine([self.to_write, self.implicit_solv])61 self.replace_val("pbc", "no")62 self.replace_val("rcoulomb", "0")63 self.replace_val("rvdw", "0")64 """65 Check the output messages from when running grompp to see which mdp options need to be changed66 """67 def emin(self, implicit_solvent = False):68 self.combine([self.heading, self.run_param, self.neigbours, self.electrostatics])69 self.replace_val("integrator", "steep")70 self.replace_val("nstlist", "1")71 if implicit_solvent:72 self.add_is()73 self.file_name = "emin"74 def nvt(self, implicit_solvent = False):75 #TODO76 self.combine([self.heading, self.run_param, self.output_control, self.bond_params, self.neigbours, self.electrostatics, self.temp_couple, self.pressure_couple, self.others])77 self.replace_val("pcoupl", "no")78 if implicit_solvent:79 self.add_is()80 self.file_name = "nvt"81 def npt(self, implicit_solvent = False):82 #TODO83 self.combine([self.heading, self.run_param, self.output_control, self.bond_params, self.neigbours, self.electrostatics, self.temp_couple, self.pressure_couple, self.others])84 self.replace_val("gen_vel", "no")85 if implicit_solvent:86 self.add_is()87 self.file_name = "npt"88 def production(self, implicit_solvent = False):89 #TODO90 self.combine([self.heading, self.run_param, self.output_control, self.bond_params, self.neigbours, self.electrostatics, self.temp_couple, self.pressure_couple, self.others])91 self.replace_val("gen_vel", "no")92 if implicit_solvent:93 self.add_is()94 self.file_name = "production"95 def pulled(self, implicit_solvent = False):96 #TODO97 self.combine([self.heading, self.run_param, self.output_control, self.bond_params, self.neigbours, self.electrostatics, self.temp_couple, self.pressure_couple, self.others, self.pull ])98 self.replace_val("gen_vel", "no")99 if implicit_solvent:100 self.add_is()101 self.file_name = "pull"102 def us(self, implicit_solvent = False):103 #TODO104 if implicit_solvent:105 self.add_is()106 return107 def reset_counter(self): self.counter = 0108 def write(self, file_name = None, postfix = False):109 """110 -Putting equals between key value pair111 -stringfy numbers112 """...

Full Screen

Full Screen

gan_configurator.py

Source:gan_configurator.py Github

copy

Full Screen

1class Automated_config_setup:2 """3 Class manages updating default GAN factor dictionary with updated values for factors modified in a screening study.4 """5 def __init__(self):6 self.temp = None7 def check_key_exists(self, dictionary, find_key):8 """9 Check if factor exists in nested10 :param dictionary: factor setting dictionary11 :param find_key: factor name12 :return:13 """14 if isinstance(dictionary, list):15 for d in dictionary:16 for result in self.check_key_exists(d, find_key):17 yield result18 if isinstance(dictionary, dict):19 for k, v in dictionary.items():20 if find_key == k:21 yield True22 if isinstance(v, dict):23 for result in self.check_key_exists(v, find_key):24 yield result25 elif isinstance(v, list):26 for d in v:27 for result in self.check_key_exists(d, find_key):28 yield result29 def replace_value_original(self, dictionary, find_key, replace_val):30 """31 Replace defalut value with updated setting for nested dictionary32 :param dictionary: factor default setting dictionary33 :param find_key: factor name34 :param replace_val: updated value35 :return:36 """37 if find_key in dictionary:38 dictionary[find_key] = replace_val39 yield dictionary[find_key]40 for k in dictionary:41 if isinstance(dictionary[k], list):42 for i in dictionary[k]:43 for j in self.replace_value(i, find_key, replace_val):44 yield j45 def replace_value(self, dictionary, find_key, replace_val):46 """47 replace default value in sub-dictionary48 :param dictionary: factor default setting dictionary49 :param find_key: factor name50 :param replace_val: updated value51 :return:52 """53 if isinstance(dictionary, list):54 for d in dictionary:55 for result in self.replace_value(d, find_key, replace_val):56 yield result57 if isinstance(dictionary, dict):58 for k, v in dictionary.items():59 if find_key == k:60 dictionary[find_key] = replace_val61 yield dictionary[find_key]62 if isinstance(v, dict):63 for result in self.replace_value(v, find_key, replace_val):64 yield result65 elif isinstance(v, list):66 for d in v:67 for result in self.replace_value(d, find_key, replace_val):68 yield result69 def update_default_setting(self, dictionary, find_key, replace_val):70 """71 Update dictionary factor with new setting. searches nested dictionarys for any instance of factor key72 """73 if len(list(self.check_key_exists(dictionary, find_key))) != 0:74 list(self.replace_value(dictionary, find_key, replace_val))75 return dictionary76 else:77 return dictionary78 def map_params(self, single_config, dictionary):79 """80 Update default dictionary with a configuration of new settings for a subset of all dictionary factor keys.81 :param single_config:82 :param dictionary:83 :return:84 """85 for factor_name, factor_setting in zip(single_config.index, single_config):86 dictionary = self.update_default_setting(dictionary, factor_name, factor_setting)...

Full Screen

Full Screen

tokenizer.py

Source:tokenizer.py Github

copy

Full Screen

1import spacy2import random34class Tokenizer:5 nlp = spacy.load('en_core_web_lg')6 input_str = None7 tokens = None8 city_list = ['Perrsia','Australia','Armenia','Russia','Sweden','Switzerland','India','LosAngels','Egypt']9 final_map = dict()10 11 def __init__(self, string):12 self.input_str = string13 self.tokens = self.nlp(self.input_str)14 15 def getLocations(self):16 self.locations = self.tokens.ents17 return self.locations18 19 def doSomething(self):20 self.split_str = self.input_str.split(' ')21 print(self.split_str)22 m = list()23 for loc in self.locations:24 x = str(loc)25 m.append(x.split(' '))2627 for cities in m:28 idx = self.split_str.index(cities[0])29 if len(cities) == 1:30 replace_val = random.choice(self.city_list)31 print(replace_val)32 self.final_map[replace_val] = self.split_str[idx]33 self.split_str[idx] = replace_val34 else:35 end_idx = self.split_str.index(cities[-1])36 replace_val = random.choice(self.city_list)37 self.final_map[replace_val] = self.split_str[idx:end_idx+1]38 self.split_str[idx] = replace_val39 for i in range(idx+1,end_idx+1):40 self.split_str.remove(self.split_str[i])41 42 def getFinal(self):43 return self.split_str4445 def getJson(self):46 return self.final_map ...

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 localstack 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