Best Python code snippet using robotframework
point_graph_printer.py
Source:point_graph_printer.py
1from __future__ import print_function, absolute_import, division #makes KratosMultiphysics backward compatible with python 2.6 and 2.72# importing the Kratos Library3from KratosMultiphysics import *4CheckForPreviousImport()5class PrintGraphPrinter:6 def __init__(self, output_nodes_list,7 model_part, variables_dictionary, domain_size):8 self.model_part = model_part9 self.outfile_list = []10 self.point_list = []11 self.var_list = []12 self.N = []13 self.elem_list = []14 self.is_scalar_var = []15 self.point_locator = PointLocation(model_part)16 for item in output_nodes_list:17 pos = item[0]18 var = variables_dictionary[item[1]]19 shape_functions = Vector(4)20 X = pos[0]21 Y = pos[1]22 Z = pos[2]23 # find the element where the node falls24 if domain_size == 2:25 Id = self.point_locator.Find2D(X, Y, shape_functions)26 else:27 Id = self.point_locator.Find3D(X, Y, Z, shape_functions)28 found_point = self.point_locator.found()29 if(found_point):30 outfile = open(item[2], 'w')31 elem = self.model_part.Elements[Id]32 if((isinstance(elem.GetNodes()[0].GetSolutionStepValue(var, 0), int)) or (isinstance(elem.GetNodes()[0].GetSolutionStepValue(var, 0), float))):33 self.is_scalar_var.append(True)34 else:35 self.is_scalar_var.append(False)36 aaa = str("#output for var: ") + str(item[1]) + str(37 " on node with coord") + str(item[0]) + "\n"38 outfile.write(aaa)39 self.N.append(shape_functions)40 self.outfile_list.append(outfile)41 self.point_list.append(pos)42 self.var_list.append(var)43 self.elem_list.append(elem)44 def PrintGraphs(self, time):45 for i in range(0, len(self.outfile_list)):46 N = self.N[i]47 outfile = self.outfile_list[i]48 var = self.var_list[i]49 elem = self.elem_list[i]50 if(self.is_scalar_var[i]):51 result = 0.052 for node, N in zip(elem.GetNodes(), N):53 result += N * node.GetSolutionStepValue(var, 0)54 aaa = str(time) + str(" ") + str(result) + str(" \n")55 outfile.write(aaa)56 else:57 result = Vector(3)58 result[0] = 0.059 result[1] = 0.060 result[2] = 0.061 for node, N in zip(elem.GetNodes(), N):62 a = node.GetSolutionStepValue(var, 0)63 result[0] += N * a[0]64 result[1] += N * a[1]65 result[2] += N * a[2]66 aaa = str(time) + str(" ") + str(result[0]) + " " + str(67 result[1]) + " " + str(result[2]) + str(" \n")68 outfile.write(aaa)69 outfile.flush()70 #71 def Close():72 for item in self.outfile_list:73 item.close()74 #75 def identity(item):76 return item77 #78 def first(iterable, predicate=identity):79 for item in iterable:80 if predicate(item):81 return item...
__init__.py
Source:__init__.py
...33def is_var(string, identifiers='$@&'):34 """Deprecated since RF 3.2. Use ``is_variable`` instead."""35 warnings.warn(is_var.__doc__, UserWarning)36 return is_variable(string, identifiers)37def is_scalar_var(string):38 """Deprecated since RF 3.2. Use ``is_scalar_variable`` instead."""39 warnings.warn(is_scalar_var.__doc__, UserWarning)40 return is_scalar_variable(string)41def is_list_var(string):42 """Deprecated since RF 3.2. Use ``is_list_variable`` instead."""43 warnings.warn(is_list_var.__doc__, UserWarning)44 return is_list_variable(string)45def is_dict_var(string):46 """Deprecated since RF 3.2. Use ``is_dict_variable`` instead."""47 warnings.warn(is_dict_var.__doc__, UserWarning)48 return is_dict_variable(string)49def contains_var(string, identifiers='$@&'):50 """Deprecated since RF 3.2. Use ``contains_variable`` instead."""51 warnings.warn(contains_var.__doc__, UserWarning)...
seed.py
Source:seed.py
...7 for ok in SCALARS + LISTS:8 assert is_var(ok)9 for nok in NOKS:10 assert not is_var(nok)11 def test_is_scalar_var(self):12 for ok in SCALARS:13 assert is_scalar_var(ok)14 for nok in LISTS + NOKS:15 assert not is_scalar_var(nok)16 def test_is_list_var(self):17 for ok in LISTS:18 assert is_list_var(ok)19 for nok in SCALARS + NOKS:20 assert not is_list_var(nok)21 def test_contains_var(self):22 for ok in SCALARS + LISTS + ['hi ${var}', '@{x}y', '${no ${yes}!']:23 assert contains_var(ok)24 for nok in [None, 42, unittest, '', 'nothing', '${no', '*{not}']:25 assert not contains_var(nok)26if __name__ == '__main__':...
test_isvar.py
Source:test_isvar.py
...6 for ok in SCALARS + LISTS:7 assert is_var(ok)8 for nok in NOKS:9 assert not is_var(nok)10 def test_is_scalar_var(self):11 for ok in SCALARS:12 assert is_scalar_var(ok)13 for nok in LISTS + NOKS:14 assert not is_scalar_var(nok)15 def test_is_list_var(self):16 for ok in LISTS:17 assert is_list_var(ok)18 for nok in SCALARS + NOKS:19 assert not is_list_var(nok)20 def test_contains_var(self):21 for ok in SCALARS + LISTS + ['hi ${var}', '@{x}y', '${no ${yes}!']:22 assert contains_var(ok)23 for nok in [None, 42, unittest, '', 'nothing', '${no', '*{not}']:24 assert not contains_var(nok)25if __name__ == '__main__':...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!