How to use _str_to_num method in autotest

Best Python code snippet using autotest_python

parse_sos_data.py

Source:parse_sos_data.py Github

copy

Full Screen

...50 return np.vstack(mu_sections)51 def visit_mu_section(self, node, visited_children):52 _, _, mu_photon_, _, _, _, _, _ = node.children53 _, _, _, _, _, _, _, data_rows = visited_children54 mu_photon = self._str_to_num(mu_photon_.text.strip())55 if mu_photon == -0.5:56 theta_photon = 60.057 elif mu_photon == -0.866025:58 theta_photon = 30.059 else:60 pass61 data = np.zeros((13*4, 6))62 data[:, 1:] = np.array(data_rows)63 data[:, 0] = theta_photon64 return data65 def visit_data_row(self, node, visited_children):66 theta_, _, phi_, _, r_i_, _, r_q_, _, r_u_, *_ = node.children67 theta = self._str_to_num(theta_.text.strip())68 phi = self._str_to_num(phi_.text.strip())69 r_i = self._str_to_num(r_i_.text.strip())70 r_q = self._str_to_num(r_q_.text.strip())71 r_u = self._str_to_num(r_u_.text.strip())72 return theta, phi, r_i, r_q, r_u73 def visit_empty(self, node, visited_children):74 return None75 def generic_visit(self, node, visited_children):76 """ The generic visit method. """77 return visited_children or node78 def _str_to_num(self, num_str):79 """ Converts number-matched string to an int or float. """80 try:81 return float(num_str)82 except ValueError:83 E_idx = num_str.find("E")84 sig = float(num_str[:E_idx])85 exp = float(num_str[E_idx + 1:])86 val = sig * math.pow(10.0, exp)87 return val88 89 # Avoid some floating point awkwardness90 # We can assume that values in this format are whole-number angles91 # return round(val, 1)92def parse_text(text):...

Full Screen

Full Screen

parse_natraj_data.py

Source:parse_natraj_data.py Github

copy

Full Screen

...55 output[mu0] = row[mu0]56 return {albedo[1]: output}57 def visit_data_row(self, node, visited_children):58 mu0_, _, mu_, _, phi0_, _, phi30_, _, phi60_, _, phi90_, _, phi120_, _, phi150_, _, phi180_, _ = visited_children59 mu0 = self._str_to_num(mu0_.text.strip())60 mu = self._str_to_num(mu_.text.strip())61 phi0 = self._str_to_num(phi0_.text.strip())62 phi30 = self._str_to_num(phi30_.text.strip())63 phi60 = self._str_to_num(phi60_.text.strip())64 phi90 = self._str_to_num(phi90_.text.strip())65 phi120 = self._str_to_num(phi120_.text.strip())66 phi150 = self._str_to_num(phi150_.text.strip())67 phi180 = self._str_to_num(phi180_.text.strip())68 return {mu0: {mu: {0.0: phi0, 30.0: phi30, 60.0: phi60, 90.0: phi90, 120.0: phi120, 150.0: phi150, 180.0: phi180}}}69 def visit_pair(self, node, visited_children):70 """ Gets each key/value pair, returns a tuple. """71 key_, _, value_, *_ = node.children72 key = key_.text.strip()73 value = self._str_to_num(value_.text.strip())74 return key, value75 def visit_empty(self, node, visited_children):76 return None77 def generic_visit(self, node, visited_children):78 """ The generic visit method. """79 return visited_children or node80 def _str_to_num(self, num_str):81 """ Converts number-matched string to a float. """82 return float(num_str)83def parse_text(text):84 # Parse the text into AST85 tree = grammar.parse(text)86 # Convert AST to dictionary87 pv = PrintVisitor()88 output = pv.visit(tree)89 return output90def parse_file(filename):91 with open(filename, 'r') as f:92 output = parse_text(f.read())93 return output94if __name__ == '__main__':...

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