How to use parse_results method in autotest

Best Python code snippet using autotest_python

parse_results.py

Source:parse_results.py Github

copy

Full Screen

...4base_dir = "../results_cifar10"5parse_results = partial(parse_results, base_dir=base_dir)6output_excel = partial(output_excel, base_dir=base_dir)7for model_type in ["plain", "linf", "l2"]:8 df = parse_results(model_type, "li", "df", sort_column="li_corr")9 output_excel(df, model_type, "li", "df")10for model_type in ["plain", "linf", "l2"]:11 df = parse_results(model_type, "li", "bethge", sort_column="li_corr")12 output_excel(df, model_type, "li", "bethge")13for model_type in ["plain", "linf", "l2"]:14 df = parse_results(model_type, "li", "daa", sort_column="acc_adv", group_by="attack_eps")15 output_excel(df, model_type, "li", "daa", group_by="attack_eps")16for model_type in ["plain", "linf", "l2"]:17 df = parse_results(model_type, "li", "pgd", sort_column="acc_adv", group_by="attack_eps")18 output_excel(df, model_type, "li", "pgd", group_by="attack_eps")19for model_type in ["plain", "linf", "l2"]:20 df = parse_results(model_type, "li", "fab")21 output_excel(df, model_type, "li", "fab")22for model_type in ["plain", "linf", "l2"]:23 df = parse_results(model_type, "li", "our_li", group_by="attack_loop_number_restarts")24 output_excel(df, model_type, "li", "our_li", group_by="attack_loop_number_restarts")25for model_type in ["plain", "linf", "l2"]:26 df = parse_results(model_type, "l2", "df")27 output_excel(df, model_type, "l2", "df")28for model_type in ["plain", "linf", "l2"]:29 df = parse_results(model_type, "l2", "cw")30 output_excel(df, model_type, "l2", "cw")31for model_type in ["plain", "linf", "l2"]:32 df = parse_results(model_type, "l2", "ddn")33 output_excel(df, model_type, "l2", "ddn")34for model_type in ["plain", "linf", "l2"]:35 df = parse_results(model_type, "l2", "bethge")36 output_excel(df, model_type, "l2", "bethge")37for model_type in ["plain", "linf", "l2"]:38 df = parse_results(model_type, "l2", "pgd", sort_column="acc_adv", group_by="attack_eps")39 output_excel(df, model_type, "l2", "pgd", group_by="attack_eps")40for model_type in ["plain", "linf", "l2"]:41 df = parse_results(model_type, "l2", "fab")42 output_excel(df, model_type, "l2", "fab")43for model_type in ["plain", "linf", "l2"]:44 df = parse_results(model_type, "l2", "our_l2", group_by="attack_loop_number_restarts")45 output_excel(df, model_type, "l2", "our_l2", group_by="attack_loop_number_restarts")46for model_type in ["plain", "linf", "l2"]:47 df = parse_results(model_type, "l1", "sparsefool")48 output_excel(df, model_type, "l1", "sparsefool")49for model_type in ["plain", "linf", "l2"]:50 df = parse_results(model_type, "l1", "ead")51 output_excel(df, model_type, "l1", "ead")52for model_type in ["plain", "linf", "l2"]:53 df = parse_results(model_type, "l1", "bethge")54 output_excel(df, model_type, "l1", "bethge")55for model_type in ["plain", "linf", "l2"]:56 df = parse_results(model_type, "l1", "pgd", sort_column="acc_adv", group_by="attack_eps")57 output_excel(df, model_type, "l1", "pgd", group_by="attack_eps")58for model_type in ["plain", "linf", "l2"]:59 df = parse_results(model_type, "l1", "fab")60 output_excel(df, model_type, "l1", "fab")61for model_type in ["plain", "linf", "l2"]:62 df = parse_results(model_type, "l1", "our_l1", group_by="attack_loop_number_restarts")63 output_excel(df, model_type, "l1", "our_l1", group_by="attack_loop_number_restarts")64for model_type in ["plain", "linf", "l2"]:65 df = parse_results(model_type, "l1", "sparsefool", sort_column="l0_corr")66 output_excel(df, model_type, "l0", "sparsefool")67for model_type in ["plain", "linf", "l2"]:68 df = parse_results(model_type, "l0", "jsma")69 output_excel(df, model_type, "l0", "jsma")70for model_type in ["plain", "linf", "l2"]:71 df = parse_results(model_type, "l0", "one_pixel")72 output_excel(df, model_type, "l0", "one_pixel")73for model_type in ["plain", "linf", "l2"]:74 df = parse_results(model_type, "l0", "bethge")75 output_excel(df, model_type, "l0", "bethge")76for model_type in ["plain", "linf", "l2"]:77 df = parse_results(model_type, "l0", "cornersearch")78 output_excel(df, model_type, "l0", "cornersearch")79for model_type in ["plain", "linf", "l2"]:80 df = parse_results(model_type, "l0", "pgd", sort_column="acc_adv", group_by="attack_eps")81 output_excel(df, model_type, "l0", "pgd", group_by="attack_eps")82for model_type in ["plain", "linf", "l2"]:83 df = parse_results(model_type, "l0", "our_l0", group_by="attack_loop_number_restarts")...

Full Screen

Full Screen

search_state_tests.py

Source:search_state_tests.py Github

copy

Full Screen

1import re2import unittest3from django.test import TestCase4from django.contrib.auth.models import AnonymousUser5from askbot.search.state_manager import SearchState, ViewLog, parse_query6from askbot import const7DEFAULT_SORT = const.DEFAULT_POST_SORT_METHOD8class SearchStateTests(TestCase):9 def setUp(self):10 self.state = SearchState()11 self.log = ViewLog()12 def visit_page(self, page_name):13 """page_name is name of the view function14 that is to be "visited"15 """16 self.log.set_current(page_name)17 def update(self, data, user = None):18 self.visit_page('questions')19 if user is None:20 user = AnonymousUser()21 self.state.update(data, self.log, user)22 def add_tag(self, tag):23 self.update({'tags': set([tag])})24 def remove_tag(self, tag):25 self.update({'remove_tag': tag})26 def assert_tags_are(self, *args):27 self.assertEqual(self.state.tags, set(args))28 def test_add_remove_tags(self):29 self.add_tag('tag1')30 self.assert_tags_are('tag1')31 self.add_tag('tag2')32 self.assert_tags_are('tag1', 'tag2')33 self.add_tag('tag3')34 self.assert_tags_are('tag1', 'tag2', 'tag3')35 self.remove_tag('tag3')36 self.assert_tags_are('tag1', 'tag2')37 self.remove_tag('tag2')38 self.assert_tags_are('tag1')39 self.remove_tag('tag1')40 self.assertEqual(len(self.state.tags), 0)41 def test_query_and_tags1(self):42 self.update({'query': 'hahaha'})43 self.add_tag('tag1')44 self.assertEquals(self.state.query, 'hahaha')45 self.assert_tags_are('tag1')46 self.update({'reset_query': True})47 self.assertEquals(self.state.query, None)48 self.assert_tags_are('tag1')49 def test_start_over(self):50 self.update({'query': 'hahaha'})51 self.add_tag('tag1')52 self.update({'start_over': True})53 self.assertEquals(self.state.query, None)54 self.assertEquals(self.state.tags, None)55 def test_auto_reset_sort(self):56 self.update({'sort': 'age-asc'})57 self.assertEquals(self.state.sort, 'age-asc')58 self.update({})59 self.assertEquals(self.state.sort, DEFAULT_SORT)60class ParseQueryTests(unittest.TestCase):61 def test_extract_users(self):62 text = '@anna haha @"maria fernanda" @\'diego maradona\' hehe [user:karl marx] hoho user:\' george bush \''63 parse_results = parse_query(text)64 self.assertEquals(65 sorted(parse_results['query_users']),66 sorted(['anna', 'maria fernanda', 'diego maradona', 'karl marx', 'george bush'])67 )68 self.assertEquals(parse_results['stripped_query'], 'haha hehe hoho')69 def test_extract_tags(self):70 text = '#tag1 [tag: tag2] some text [tag3] query'71 parse_results = parse_query(text)72 self.assertEquals(set(parse_results['query_tags']), set(['tag1', 'tag2', 'tag3']))73 self.assertEquals(parse_results['stripped_query'], 'some text query')74 def test_extract_title1(self):75 text = 'some text query [title: what is this?]'76 parse_results = parse_query(text)77 self.assertEquals(parse_results['query_title'], 'what is this?')78 self.assertEquals(parse_results['stripped_query'], 'some text query')79 def test_extract_title2(self):80 text = 'some text query title:"what is this?"'81 parse_results = parse_query(text)82 self.assertEquals(parse_results['query_title'], 'what is this?')83 self.assertEquals(parse_results['stripped_query'], 'some text query')84 def test_extract_title3(self):85 text = 'some text query title:\'what is this?\''86 parse_results = parse_query(text)87 self.assertEquals(parse_results['query_title'], 'what is this?')88 self.assertEquals(parse_results['stripped_query'], 'some text query')89 def test_negative_match(self):90 text = 'some query text'91 parse_results = parse_query(text)...

Full Screen

Full Screen

CLIArgumentsProcessor.py

Source:CLIArgumentsProcessor.py Github

copy

Full Screen

1import argparse as agp2import getpass3import Obfuscator as ob4import os56class CLIArgumentsProcessor:7 """This class processes the arguments from the command line interface (CLI), checks if the necessary arguments have been provided and then returns them as8 a dictionary to the caller"""910 def get_parameters(self)->dict:1112 params_dict:dict = None1314 try:15 parser:agp.ArgumentParser = agp.ArgumentParser(add_help=True)1617 #Add all arguments to the parser18 parser.add_argument("-t"\19 , "--TrustedConnection"\20 , dest="trusted_mode"\21 , action = 'store'\22 , default = False\23 , help="Use the MS SQL Server in Trusted Connection mode (default=false)"\24 , type=bool)25 26 parser.add_argument("-d"\27 , "--DSN"\28 , dest="dsn" \29 , action = 'store'\30 , default = None \31 , help="The MS SQL Server DSN descriptor file"\32 , type=str)33 34 parser.add_argument("-s"\35 , "--DBServer"\36 , dest="server"37 , action = 'store'\38 , default = None\39 , help="The MS SQL Server database server name"\40 , type=str)41 42 parser.add_argument("-n"\43 , "--DBName"\44 , dest="db_name"\45 , action = 'store'\46 , default = None\47 , help="The MS-SQL Server database name"\48 , type=str)4950 parser.add_argument("-u"\51 , "--DBUser"\52 , dest="username"\53 , action = 'store'\54 , default = None\55 , help="The MS SQL Server database username"\56 , type=str)5758 parser.add_argument("-v"\59 , "--ViewName"\60 , dest="viewname"\61 , action = 'store'\62 , default = "dbo.vw_AllSurveyData"\63 , help="The MS SQL Server view name to be used (e.g. SCHEMA.VIEWNAME)"\64 , type=str)6566 parser.add_argument("-f"\67 , "--PersistenceFilePath"\68 , dest="persistencefilepath"\69 , action = 'store'\70 , default = os.getcwd() + os.sep + "surveyStructure_LATEST.pkl"\71 , help="The serialised persistence file path (defaulted to os.getcwd() + os.sep + surveyStructure_LATEST.pkl)"\72 , type=str)7374 #Now parse the results75 parse_results:agp.Namespace = parser.parse_args()7677 #Certain parameters must be provided by the user. If they are not raise an exception.78 if(parse_results.db_name is None):79 raise Exception("A database name must be provided using the -n or --DBName command line argument")8081 if(parse_results.server is None):82 raise Exception("A database server name must be provided using the -s or --DBServer command line argument")8384 #When not in trusted mode a username and password must be provided85 if(parse_results.trusted_mode == False):86 if(parse_results.username is None):87 raise Exception("A database username must be provided using the -u or --DBUser command line argument")8889 #Prompt for the password and encrypt it. It should not be provided directly in cleartext.90 obfuscator = ob.Obfuscator()91 encrypted_pwd = obfuscator.obfuscate(getpass.getpass('Please enter the database password (no echo)'))92 else:93 #We are in trusted mode but the username is not required, so ignore it.94 if(parse_results.username is not None):95 raise Exception("The trusted connection is being used and the database user name has been provided. The username will be ignored.")9697 #Place all the CLI parameters into a dictionary98 params_dict = {99 "trusted_mode": parse_results.trusted_mode,100 "dsn":parse_results.dsn,101 "server":parse_results.server,102 "db_name":parse_results.db_name,103 "username":parse_results.username,104 "password": encrypted_pwd,105 "viewname": parse_results.viewname,106 "persistencefilepath":parse_results.persistencefilepath107 }108109 except Exception as e:110 print("CLIArgumentsProcessor:get_parameters()-> A command line arguments processing error has occurred:" + str(e))111 ...

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