How to use str_ignore method in autotest

Best Python code snippet using autotest_python

regression.py

Source:regression.py Github

copy

Full Screen

...278 param prefix1: output prefix in Avg/SD lines279 param prefix2: output prefix in Diff Avg/P-value lines280 param prefix3: output prefix in total Sign line281 """282 def str_ignore(str, split=False):283 str = str.split("|")284 for i in range(ignore_col):285 str[i] = " "286 if split:287 return "|".join(str[ignore_col:])288 return "|".join(str)289 def tee_line(content, file, n=None):290 fd = open(file, "a")291 print content292 str = ""293 str += "<TR ALIGN=CENTER>"294 content = content.split("|")295 for i in range(len(content)):296 if n and i >= 2 and i < ignore_col + 2:297 str += "<TD ROWSPAN=%d WIDTH=1%% >%s</TD>" % (n, content[i])298 else:299 str += "<TD WIDTH=1%% >%s</TD>" % content[i]300 str += "</TR>"301 fd.write(str + "\n")302 fd.close()303 for l in range(len(lists[0])):304 if not re.findall("[a-zA-Z]", lists[0][l]):305 break306 tee("<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=1 width=10%><TBODY>",307 f)308 tee("<h3>== %s " % sum + "==</h3>", f)309 category = 0310 for i in range(len(lists[0])):311 for n in range(len(lists)):312 is_diff = False313 for j in range(len(lists)):314 if lists[0][i] != lists[j][i]:315 is_diff = True316 if len(lists) == 1 and not re.findall("[a-zA-Z]", lists[j][i]):317 is_diff = True318 pfix = prefix1[0]319 if len(prefix1) != 1:320 pfix = prefix1[n]321 if is_diff:322 if n == 0:323 tee_line(pfix + lists[n][i], f, n=len(lists) + len(rates))324 else:325 tee_line(pfix + str_ignore(lists[n][i], True), f)326 if not is_diff and n == 0:327 if '|' in lists[n][i]:328 tee_line(prefix0 + lists[n][i], f)329 elif "Category:" in lists[n][i]:330 if category != 0 and prefix3:331 if len(allpvalues[category - 1]) > 0:332 tee_line(prefix3 + str_ignore(333 allpvalues[category - 1][0]), f)334 tee("</TBODY></TABLE>", f)335 tee("<br>", f)336 tee("<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=1 "337 "width=10%><TBODY>", f)338 category += 1339 tee("<TH colspan=3 >%s</TH>" % lists[n][i], f)340 else:341 tee("<TH colspan=3 >%s</TH>" % lists[n][i], f)342 for n in range(len(rates)):343 if lists[0][i] != rates[n][i] and not re.findall("[a-zA-Z]",344 rates[n][i]):345 tee_line(prefix2[n] + str_ignore(rates[n][i], True), f)346 if prefix3 and len(allpvalues[-1]) > 0:347 tee_line(prefix3 + str_ignore(allpvalues[category - 1][0]), f)348 tee("</TBODY></TABLE>", f)349def analyze(test, type, arg1, arg2, configfile):350 """ Compute averages/p-vales of two samples, print results nicely """351 config = ConfigParser.ConfigParser()352 config.read(configfile)353 ignore_col = int(config.get(test, "ignore_col"))354 avg_update = config.get(test, "avg_update")355 desc = config.get(test, "desc")356 def get_list(dir):357 result_file_pattern = config.get(test, "result_file_pattern")358 cmd = 'find %s|grep "%s.*/%s"' % (dir, test, result_file_pattern)359 print cmd360 return commands.getoutput(cmd)361 if type == 'file':...

Full Screen

Full Screen

palavras.py

Source:palavras.py Github

copy

Full Screen

1import csv2def gerarSet(string):3 temp_set = set()4 for x in string:5 temp_set.add(x)6 return temp_set7def retirarIgnores(frase, set_ignore):8 for letra in frase:9 if letra in set_ignore:10 frase = frase.replace(letra, '')11 return frase12def palavrasNoDicionario(dicionario, palavrasFrase):13 temp_list_erratas = []14 for palavra in palavrasFrase:15 if palavra not in dicionario:16 temp_list_erratas.append(palavra)17 return temp_list_erratas18def notasIntencoes(dicionarioIntencoes, frase):19 temp_dict_notas = {}20 contador = 121 for palavra in frase:22 for intencao in dicionarioIntencoes.keys():23 if palavra in dicionarioIntencoes[intencao]:24 if intencao not in temp_dict_notas:25 temp_dict_notas[intencao] = 026 temp_dict_notas[intencao] += 1 * contador27 contador += 128 return temp_dict_notas29def analiseIntecoes(dicionario_notas_intencoes):30 if len(dicionario_notas_intencoes.keys()) == 0:31 return ""32 lista_keys = []33 for i in dicionario_notas_intencoes.keys():34 lista_keys.append(i)35 intencao_atual = lista_keys[0]36 intencao_atual_nota = dicionario_notas_intencoes[lista_keys[0]]37 for intencao in dicionario_notas_intencoes.keys():38 if dicionario_notas_intencoes[intencao] > intencao_atual_nota:39 intencao_atual_nota = dicionario_notas_intencoes[intencao]40 intencao_atual = intencao41 return intencao_atual42str_letras = "abcdefghijklmnopqrstuvwxyz"43str_ignore = "1234567890()*&%$#@!',./?"44set_letras = gerarSet(str_letras)45set_ignore = gerarSet(str_ignore)46with open('pt_br.txt', 'r', encoding='ISO-8859-1') as f:47 palavras = f.read().split('\n')48with open('intencoes.csv', 'r', encoding='utf8') as csv_f:49 csv_reader = csv.reader(csv_f, delimiter=';')50 dict_intencoes = {}51 linha_counter = 052 for linha in csv_reader:53 if linha_counter == 0:54 linha_counter += 155 continue56 if linha[0] not in dict_intencoes:57 dict_intencoes[linha[0]] = []58 dict_intencoes[linha[0]].append(linha[1])59sair = False60context = []61def conversa(input):62 input = retirarIgnores(input.lower(), set_ignore)63 dict_retorno = {}64 frase_separada = input.split()65 erratas = palavrasNoDicionario(palavras, frase_separada)66 notas_intencoes = notasIntencoes(dict_intencoes, frase_separada)67 intencao = analiseIntecoes(notas_intencoes)68 if len(erratas) > 0:69 dict_retorno['speelCheck'] = 'error'70 dict_retorno['erratas'] = erratas71 else:72 context.append(intencao)73 dict_retorno['spellChack'] = 'ok'74 dict_retorno['response'] = {}75 dict_retorno['response']['intencao'] = intencao76 dict_retorno['response']['notas'] = notas_intencoes77 return dict_retorno78while sair != True:79 frase = retirarIgnores(input("Input: "), set_ignore).lower()80 response = conversa(frase)81 if 'response' in response:82 if response['response']['intencao'] == 'sair':83 break84 elif response['response']['intencao'] == 'reset':85 context.clear()...

Full Screen

Full Screen

bowling.py

Source:bowling.py Github

copy

Full Screen

1import re2import numpy as np3import pandas as pd4from .scrapers import get_innings_by_innings_stats5default_renames = {"mdns": "maidens",6 "wkts": "wickets",7 "econ": "economy",8 "pos": "position",9 "inns": "innings"}10default_deletes = ['nan', 'DNB', 'TDNB']11def total_balls(overs_str, str_ignore=['DNB', 'TDNB'], ignore_value=0):12 """13 Calculate total balls bowled from overs formatting14 Parameters15 ----------16 overs_str: string17 Overs bowled in traditional format overs.balls18 str_ignore: list19 Strings to ignore and return 0 - indicators that the player didn't bowl20 ignore_value: int21 Value to input for strings matched into str_ignore22 Returns23 -------24 int:25 The number of balls bowled as an int26 """27 if overs_str in str_ignore:28 return ignore_value29 grouping_re = re.compile(r'^([0-9]*)\.([0-5]*)$').search(overs_str)30 if grouping_re is None:31 return int(overs_str) * 632 else:33 overs = int(grouping_re.group(1)) * 634 balls = int(grouping_re.group(2))35 return overs + balls36def test_innings_by_innings(player_id, column_rename=default_renames, score_deletes=default_deletes, home_or_away=-1):37 """38 Return the test innings by innings for a given player39 Parameters40 ----------41 player_id: int42 Player ID for cricketer from ESPNcricinfo43 column_rename: dict44 Rename columns old: new45 score_deletes: list46 Values to represent null47 home_or_away: int48 Value to limit to either home or away matches49 Returns50 -------51 pandas.DataFrame52 Test innings DataFrame scraped from site53 """54 raw_table = get_innings_by_innings_stats(player_id, 'Bowling', 'Test', home_or_away)55 if raw_table is None:56 return None57 raw_table.replace('-', np.nan, inplace=True)58 raw_table.columns = raw_table.columns.str.lower().str.replace(' ', '_')59 # Rename columns60 raw_table.rename(column_rename, axis=1, inplace=True)61 raw_table.runs = raw_table.runs.apply(62 lambda x: np.nan if x in score_deletes else x)63 raw_table['total_balls'] = raw_table.overs.astype(str).apply(total_balls)64 # Remove blank columns65 raw_table.drop('', axis=1, inplace=True)66 return raw_table67def test_home_or_away(player_id):68 """69 Get the test bowling innings for a given player with column indicating home/away/neutral70 Parameters71 ----------72 player_id: int73 Player ID for cricketer from ESPNcricinfo74 Returns75 -------76 pandas.DataFrame77 Test innings DataFrame scraped from site with additional home/away/neutral column78 """79 home = test_innings_by_innings(player_id, home_or_away=1)80 away = test_innings_by_innings(player_id, home_or_away=2)81 neutral = test_innings_by_innings(player_id, home_or_away=3)...

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