How to use add_attributes method in localstack

Best Python code snippet using localstack_python

test_entity.py

Source:test_entity.py Github

copy

Full Screen

...9 Entity(" PARTICIPANT: numero, nom, adresse "),10 Entity("PARTICIPANT :numero ,nom ,adresse"),11 ]12 for e in entities:13 e.add_attributes([])14 self.assertEqual(e.name, "PARTICIPANT")15 self.assertEqual(e.name_view, "PARTICIPANT")16 self.assertEqual([a.label for a in e.attributes], ["numero", "nom", "adresse"])17 self.assertEqual([a.get_category() for a in e.attributes], ["strong", "simple", "simple"])18 def test_data_types(self):19 e = Entity("PARTICIPANT: numero [type1], nom [type2] , adresse[type3]")20 e.add_attributes([])21 self.assertEqual([a.label for a in e.attributes], ["numero", "nom", "adresse"])22 self.assertEqual([a.data_type for a in e.attributes], ["type1", "type2", "type3"])23 e = Entity("PARTICIPANT: numero [type a,b,c], nom [type2], adresse [type3]")24 e.add_attributes([])25 self.assertEqual([a.data_type for a in e.attributes], ["type a,b,c", "type2", "type3"])26 e = Entity("PARTICIPANT: numero [], nom, adresse [type3]")27 e.add_attributes([])28 self.assertEqual([a.data_type for a in e.attributes], ["", None, "type3"])29 e = Entity("PARTICIPANT: numero [, nom, adresse")30 e.add_attributes([])31 self.assertEqual([a.data_type for a in e.attributes], [None, None, None])32 def test_numbered_entity(self):33 e = Entity("PARTICIPANT5: numero, nom, adresse")34 e.add_attributes([])35 self.assertEqual(e.name, "PARTICIPANT5")36 self.assertEqual(e.name_view, "PARTICIPANT")37 def test_blank(self):38 e = Entity("MOT-CLEF: mot-clé, ,")39 e.add_attributes([])40 self.assertEqual([a.label for a in e.attributes], ["mot-clé", "", ""])41 self.assertEqual([a.get_category() for a in e.attributes], ["strong", "phantom", "phantom"])42 def test_all_blank(self):43 e = Entity("BLANK: , ,")44 e.add_attributes([])45 self.assertEqual([a.label for a in e.attributes], ["", "", ""])46 self.assertEqual([a.get_category() for a in e.attributes], ["phantom", "phantom", "phantom"])47 def test_no_identifier_at_first_position(self):48 e = Entity("POSITION: _abscisse, ordonnee")49 e.add_attributes([])50 self.assertEqual([a.label for a in e.attributes], ["abscisse", "ordonnee"])51 self.assertEqual([a.get_category() for a in e.attributes], ["simple", "simple"])52 def test_no_identifier_for_children(self):53 e = Entity("POSITION: abscisse, _ordonnee")54 e.add_attributes([], is_child=True)55 self.assertEqual([a.label for a in e.attributes], ["abscisse", "ordonnee"])56 self.assertEqual([a.get_category() for a in e.attributes], ["simple", "simple"])57 def test_multiple_strong_identifier(self):58 e = Entity("POSITION: abscisse, _ordonnee")59 e.add_attributes([])60 self.assertEqual([a.label for a in e.attributes], ["abscisse", "ordonnee"])61 self.assertEqual([a.get_category() for a in e.attributes], ["strong", "strong"])62 def test_weak_identifier(self):63 e = Entity("LIVRE: Num. exemplaire, Etat du livre, Date d'achat")64 e.add_attributes(["placeholder"])65 self.assertEqual([a.label for a in e.attributes], ["Num. exemplaire", "Etat du livre", "Date d'achat"])66 self.assertEqual([a.get_category() for a in e.attributes], ["weak", "simple", "simple"])67 def test_weak_composite_identifier(self):68 e = Entity("POSITION: abscisse, _ordonnee, foobar")69 e.add_attributes(["placeholder"])70 self.assertEqual([a.label for a in e.attributes], ["abscisse", "ordonnee", "foobar"])71 self.assertEqual([a.get_category() for a in e.attributes], ["weak", "weak", "simple"])72 def test_backslash_suppression(self):73 e = Entity("PARTICIPANT\: numero\, \tnom\t, ad\\resse")74 e.add_attributes([])75 self.assertEqual(e.name, "PARTICIPANT")76 self.assertEqual(e.name_view, "PARTICIPANT")77 self.assertEqual([a.label for a in e.attributes], ["numero", "nom", "adresse"])78if __name__ == '__main__':...

Full Screen

Full Screen

displayer.py

Source:displayer.py Github

copy

Full Screen

...5import numpy as np6class NSGANetDisplay(Display):7 def _do(self, ga):8 self.display_top = -19 self.add_attributes('n_gens', ga.n_gens) 10 self.add_attributes('n_evals', ga.n_evals) 11 self.add_attributes('error_rate', ga.F_pop[ga.elite_idx])12 self.add_attributes('flops', ga.F_pop[ga.elite_idx])13 now = time.time()14 self.add_attributes('time', now - ga.start_time)15 self.add_attributes('architecture', ga.pop[ga.elite_idx])16class SODisplay(Display):17 def _do(self, algorithm):18 self.display_top = 1019 self.add_attributes('mean', algorithm.fitness_pop.mean())20 self.add_attributes('std', algorithm.fitness_pop.std())21 self.add_attributes('n_gens', algorithm.n_gens)22 self.add_attributes('n_evals', algorithm.n_evals)23 self.add_attributes('elite', algorithm.pop[algorithm.elite_idx])24def print_info(self):25 n_params = (np.sum(np.prod(v.size()) for v in filter(lambda p: p.requires_grad, self.model.parameters())) / 1e6)26 self.model = add_flops_counting_methods(self.model)27 self.model.eval()28 self.model.start_flops_count()29 random_data = torch.randn(1, *self.data_info['input_size'])30 self.model(torch.autograd.Variable(random_data).to(self.device))31 n_flops = np.round(self.model.compute_average_flops_cost() / 1e6, 4)...

Full Screen

Full Screen

logger.py

Source:logger.py Github

copy

Full Screen

1import time2from model.log_saver import LogSaver3class NSGANetLogSaver(LogSaver):4 def _do(self, ga):5 self.add_attributes('architecture', ga.pop[ga.elite_idx])6 self.add_attributes('error_rate', ga.F_pop[ga.elite_idx])7 self.add_attributes('flops', ga.F_pop[ga.elite_idx])8 self.add_attributes('n_gens', ga.n_gens) 9 self.add_attributes('n_evals', ga.n_evals) 10 11 now = time.time()12 self.add_attributes('time', now - ga.start_time)13class SOLogSaver(LogSaver):14 def _do(self, algorithm):15 self.add_attributes('mean', algorithm.fitness_pop.mean())16 self.add_attributes('std', algorithm.fitness_pop.std())17 self.add_attributes('n_gens', algorithm.n_gens)18 self.add_attributes('n_evals', algorithm.n_evals)...

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