How to use test_direct_method method in freezegun

Best Python code snippet using freezegun

main.py

Source:main.py Github

copy

Full Screen

...60 print(f"-> Simulation Time: {simulation_time:.6f} s\n")61 if render:62 dfa.render_digraph(output_filename.replace('FA', 'DFA'), view_pdf)63 print('[OUT] DFA digraph generated!')64def test_direct_method(regex, input_test = None, simulate = False, render=True, output_filename='', view_pdf=True):65 tokenizer = Tokenizer(regex, is_direct_tokenization=True)66 tokens = tokenizer.get_tokens()67 parser = TreeParser(tokens)68 tree = parser.parse()69 # Direct DFA (from regex)70 regex_dfa = RegexDFA(tree, tokenizer.symbols_stream, input_test)71 if simulate and input_test:72 start_time = process_time()73 regex_dfa.simulate()74 end_time = process_time()75 print(f"Direct DFA accepts input '{input_test}'? ", regex_dfa.regex_accept_status)76 simulation_time = end_time - start_time77 print(f"-> Simulation Time: {simulation_time:.6f} s\n")78 if render:79 regex_dfa.render_digraph(output_filename, view_pdf)80 print('[OUT] Direct DFA digraph generated!')81def main():82 option = None83 while option != 0:84 print(MAIN_MENU)85 option = int(input('> '))86 if option == 1:87 fa_option = None88 input_regex = None89 input_test = None90 while fa_option != 0:91 if not input_regex or not input_test:92 input_regex = input('Enter the regex: ')93 input_test = input('Enter the eval expr: ')94 print(FA_MENU)95 fa_option = int(input('> '))96 if fa_option == 1:97 try:98 test_thompson_and_subsets(99 regex = input_regex,100 input_test = input_test,101 simulate = True,102 render = True103 )104 except Exception as e:105 print(f'\n\tAn error ocurred, please check your regex: {e}')106 reset_regex = input('-> Do you want to reset regex expr? (y/n): ') or 'n'107 if reset_regex and reset_regex.lower() == 'y':108 input_regex = input('Enter the regex: ')109 input_test = input('Enter the eval expr: ')110 elif fa_option == 2:111 try:112 test_direct_method(113 regex = input_regex,114 input_test = input_test,115 simulate = True,116 render = True117 )118 except Exception as e:119 print(f'\n\tAn error ocurred, please check your regex: {e}')120 reset_regex = input('-> Do you want to reset regex expr? (y/n): ') or 'n'121 if reset_regex and reset_regex.lower() == 'y':122 input_regex = input('Enter the regex: ')123 input_test = input('Enter the eval expr: ')124 elif fa_option == 3:125 fa_option = 0126 else:127 print('Not a valid option, going back to main menu...')128 fa_option = 0129 elif option == 2:130 test_option = None131 while test_option != 0:132 print(TESTS_MENU)133 test_option = int(input('> '))134 if test_option == 1 or test_option == 2:135 clean_test_render_folder()136 try:137 test_lines = []138 if test_option == 1:139 # Test ABC txt file140 test_lines = load_txt_file(ABC_TEST_PATH)141 elif test_option == 2:142 # Test Binary txt file143 test_lines = load_txt_file(BINARY_TEST_PATH)144 iteration = 0145 for regex_test in test_lines:146 # Simulation input is not required, we only want to generate the NFA & DFA outputs 147 test_thompson_and_subsets(148 regex = regex_test,149 render = True,150 output_filename = f"./tests/renders/FA_{iteration}.gv",151 view_pdf = False152 )153 test_direct_method(154 regex = regex_test,155 render = True,156 output_filename = f"./tests/renders/RegexDFA_{iteration}.gv",157 view_pdf = False158 )159 iteration += 1160 print(f"-> {'ABC' if test_option == 1 else 'Binary' } tests passed!")161 except Exception as e:162 print(f'\n\tAn error ocurred, please regex on test file: {e}')163 elif test_option == 3:164 test_option = 0165 else:166 print('Not a valid option, going back to main menu...')167 test_option = 0...

Full Screen

Full Screen

test_dataframe.py

Source:test_dataframe.py Github

copy

Full Screen

...100 def test_pd_df(self):101 self.create_ionosphere(IONOSPHERE_TABLE)102 pd_df = DataFrame(self.odps.get_table(IONOSPHERE_TABLE)).to_pandas()103 @ci_skip_case104 def test_direct_method(self):105 self.create_ionosphere(IONOSPHERE_TABLE)106 df = DataFrame(self.odps.get_table(IONOSPHERE_TABLE)).roles(label='class')107 train, test = df.split(0.6)108 lr = LogisticRegression(epsilon=0.01)109 model = lr.train(train)110 predicted = model.predict(test)111 predicted.to_pandas()112 @ci_skip_case113 def test_dynamic_output(self):114 self.create_ionosphere(IONOSPHERE_TABLE)115 df = DataFrame(self.odps.get_table(IONOSPHERE_TABLE))116 df = df.roles(label=df['class'])117 filtered, importance = select_features(df)118 print(filtered.describe().execute())...

Full Screen

Full Screen

test_structural_solution.py

Source:test_structural_solution.py Github

copy

Full Screen

...24 correct_modal_shape = np.load('matrices\\structural_solution\\mode_shapes.npy')25 26 assert np.allclose(natural_frequencies, correct_natural_frequencies)27 assert np.allclose(modal_shape, correct_modal_shape)28def test_direct_method(preprocessor):29 solution = SolutionStructural(preprocessor)30 frequencies = np.arange(0, 200+1, 2)31 32 direct_method = solution.direct_method(frequencies, is_viscous_lumped=True)33 correct_direct_method = np.load('matrices\\structural_solution\\direct_method.npy')34 assert np.allclose(direct_method, correct_direct_method)35def test_mode_superposition(preprocessor):36 solution = SolutionStructural(preprocessor)37 frequencies = np.arange(0, 200+1, 2)38 modes = 20039 mode_superposition = solution.mode_superposition(frequencies, modes, fastest=True)40 correct_mode_superposition = np.load('matrices\\structural_solution\\mode_superposition.npy')...

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