Best Python code snippet using localstack_python
test_misc.py
Source:test_misc.py
...25 # test parsing26 parsed = parse_chunked_data(chunked)27 self.assertEqual(expected.strip(), parsed.strip())28 # test roundtrip29 chunked_computed = create_chunked_data(expected)30 parsed = parse_chunked_data(chunked_computed)31 self.assertEqual(expected.strip(), parsed.strip())32 def test_convert_yaml_date_strings(self):33 yaml_source = "Version: 2012-10-17"34 obj = yaml.safe_load(yaml_source)35 self.assertIn(type(obj["Version"]), (datetime.date, str))36 if isinstance(obj["Version"], datetime.date):37 obj = json_safe(obj)38 self.assertEqual(str, type(obj["Version"]))39 self.assertEqual("2012-10-17", obj["Version"])40 def test_timstamp_millis(self):41 t1 = now_utc()42 t2 = now_utc(millis=True) / 100043 self.assertAlmostEqual(t1, t2, delta=1)...
chunk_extractor.py
Source:chunk_extractor.py
...11 pad_func = (lambda x: x if x % pad_size == 0 else x - (x % pad_size) + pad_size)12 paded_image = np.zeros((pad_func(image.shape[0]), pad_func(image.shape[1]), image.shape[2]), dtype=np.uint8)13 paded_image[:image.shape[0], :image.shape[1], :] = image14 return paded_image15 def create_chunked_data(self, image):16 chunk_size = self.get_chunk_size(image)17 image = self.get_paded_image(image, chunk_size)18 chunked_data = np.split(image, image.shape[0] / chunk_size)19 chunked_data = map(lambda x: np.split(x, x.shape[1] / chunk_size, axis=1), chunked_data)20 for row_ind, row_data in enumerate(chunked_data):21 for col_ind, col_data in enumerate(row_data):22 start_x, start_y = row_ind * chunk_size, col_ind * chunk_size23 end_x, end_y = start_x + chunk_size, start_y + chunk_size24 if start_x > end_x:25 start_x, end_x = end_x, start_x26 if start_y > end_y:27 start_y, end_y = end_y, start_y28 pos_data = {'start_pos': (start_x, start_y), 'end_pos': (end_x, end_y)}29 chunked_data[row_ind][col_ind] = (pos_data, chunked_data[row_ind][col_ind])30 return [item for row in chunked_data for item in row]31 def get_fragment_list(self, image):32 fragment_shaper = FragmentShaper()33 fragment_list = self.create_chunked_data(image)34 fragment_list = map(fragment_shaper.shape_fragment, fragment_list)...
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!!