Best Python code snippet using autotest_python
savefile.py
Source: savefile.py
...41 # put network on CPU, so that it can also be opened and read on computers without a GPU42 with open(path + filename + '.save', 'wb') as file:43 pickle.dump(savefile, file)44 with open(path + 'info.txt', 'w') as info:45 info.writelines(get_info_lines(savefile))46 47def make_folder(savefile):48 path = PATH + savefile.version + '/'49 if not os.path.exists(path):50 try: os.mkdir(path)51 except OSError: print(f'Failed creating folder {path}')52 else: print(f'Successfully created folder {path}')53def load_from_disk(version):54 path = PATH + version + '/'55 files = [f for f in os.listdir(path) if '.save' in f]56 files.sort(reverse = True)57 if len(files) < 1:58 print(f'nothing to load from directory {version}/')59 exit(0)60 with open(path + files[0], 'rb') as file:61 return pickle.load(file)62def get_info_lines(savefile):63 path = PATH + savefile.version + '/'64 txt = [f'date: {datetime.datetime.now()}']65 txt.append(f'\nsimulations: {savefile.config.num_iterations}')66 txt.append(f'\nboard_size: {savefile.config.size}x{savefile.config.size}')67 txt.append(f'\nconvolutional filters: {savefile.config.num_conv_filters}')68 txt.append(f'\nresidual blocks: {savefile.config.num_res_blocks}')69 txt.append(f'\nlearning rate: {savefile.config.learning_rate}')70 txt.append(f'\ngames between training: {savefile.config.num_actors}')71 txt.append(f'\nepochs between games: {savefile.config.epochs_between_games}')72 txt.append(f'\ngame window size: {savefile.config.window_size}')73 txt.append(f'\nbatch size: {savefile.config.batch_size}')74 txt.append(f'\n\ntime elapsed: {datetime.timedelta(seconds = savefile.time_spent)} ({savefile.time_spent:.0f} seconds)')75 txt.append(f'\ngames played: {savefile.num_games_played}')76 txt.append(f'\nepochs trained: {savefile.num_epochs_trained}')...
radiance_command_getinfo_test.py
Source: radiance_command_getinfo_test.py
1import unittest2from honeybee_plus.radiance.command.getinfo import Getinfo3import os4import tempfile5class GetinfoTestCase(unittest.TestCase):6 """Test for (honeybee/radiance/command/oconv.py)."""7 # preparing to test8 def setUp(self):9 """Set up the test case by initiating the class."""10 get_info = Getinfo()11 get_info.input_file = os.path.abspath('tests/assets/sample.hdr')12 get_info.output_file = os.path.abspath(tempfile.mktemp(suffix='.txt'))13 self.getinfo_test1 = get_info14 self.output_file1 = get_info.output_file15 # ending the test16 def tearDown(self):17 """Cleaning up after the test."""18 pass19 # test default values20 def test_default_values(self):21 """The first test checks if Getinfo works. The script opens an image22 assets/sample.hdr and reads its header."""23 self.getinfo_test1.execute()24 with open(self.output_file1.to_rad_string()) as some_file:25 get_info_lines = some_file.readlines()[1].strip().split()[0]26 assert get_info_lines == '#?RADIANCE'27if __name__ == '__main__':28 # You can run the test module from the root folder by running runtestunits.py29 os.chdir(os.pardir)...
convert_log.py
Source: convert_log.py
1# class Logdocument:2# def __init__(self):3# index = 04# buffer = ""5# def get_info_lines(self, log_file: str) -> list[str]: #list = return type6# INFO_LINES=[]7# with open(log_file, 'r') as f:8# for line in f:9# if 'INFO' in line:10# INFO_LINES.append(line)11# return INFO_LINES12# def parse_devkey(self, line: str) -> int: #int = return type13# index = line.index("devkey_handle")14# buffer = line[index + 16:]15# return int(buffer.split("}")[0])16# def parse_addrehandle(self, line: str) -> int: #int = return type17# index = line.index("address_handle")18# buffer = line[index + 16:] 19# return int(buffer.split("}")[0])20# def main(self):21# lines = get_info_lines('log\COM12_21-347-22-51_output.log')22# for line in lines:23# if 'devkey_handle' in line: #zit devkey_handle in die line24# print(f'Devkey: {parse_devkey(line)}') #print de nummer van devkey25# elif 'address_handle' in line:26# print(f'address_handle: {parse_addrehandle(line)}')27#if __name__ == '__main__':28 # Logdocument()29 # main()...
Check out the latest blogs from LambdaTest on this topic:
Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.
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!!