Best Python code snippet using pandera_python
istypes_test.py
Source:istypes_test.py
...78 79 80class Test_is_bool:81 def test_int(self):82 assert not am.tools.is_bool(1)83 84 def test_long(self):85 assert not am.tools.is_bool(1L)86 def test_int_list(self):87 assert not am.tools.is_bool([1])88 89 def test_np_int32(self):90 assert not am.tools.is_bool(np.array(1, dtype='int32'))91 92 def test_np_int64(self):93 assert not am.tools.is_bool(np.array(1, dtype='int64'))94 95 def test_np_int64_list(self):96 assert not am.tools.is_bool(np.array([1], dtype='int64'))97 98 def test_bool(self):99 assert am.tools.is_bool(True)100 101 def test_bool_list(self):102 assert not am.tools.is_bool([True])103 def test_np_bool(self):104 assert am.tools.is_bool(np.array(False))105 106 def test_np_bool_list(self):107 assert not am.tools.is_bool(np.array([False]))108 109 def test_float(self):110 assert not am.tools.is_bool(1.0)111 112 def test_float_list(self):113 assert not am.tools.is_bool([1.0])114 def test_np_float(self):115 assert not am.tools.is_bool(np.array(1.0, dtype='float64'))116 117 def test_np_float_list(self):118 assert not am.tools.is_bool(np.array([1.0], dtype='float64'))119 120 def test_str(self):121 assert not am.tools.is_bool('1')122 123 def test_np_str(self):124 assert not am.tools.is_bool(np.array('1')) 125class Test_is_dtype_bool:126 def test_int(self):127 value = np.array(52, dtype=int)128 assert not am.tools.is_dtype_bool(value.dtype)129 def test_long(self):130 value = np.array(52, dtype=long)131 assert not am.tools.is_dtype_bool(value.dtype)132 133 def test_int32(self):134 value = np.array(52, dtype='int32')135 assert not am.tools.is_dtype_bool(value.dtype)136 def test_int64(self):137 value = np.array(52, dtype='int64')138 assert not am.tools.is_dtype_bool(value.dtype)...
sensor_bayer_pattern.py
Source:sensor_bayer_pattern.py
1from collections import namedtuple2import numpy as np3"""4RGGB5"""6BAYER_RGGB_CHANNEL_LOC_MAP = {7 'r': (0, 0),8 'g1': (0, 1),9 'g2': (1, 0),10 'b': (1, 1)11}12def generate_rggb_pattern_map(height, width, channel, is_bool=False):13 assert channel == 'r' or channel == 'g1' or channel == 'g2' or channel == 'b', \14 "Invalid RGGB Bayer channel. The `channel` must be in one of {r, g1, g2, b}."15 period_length = 216 start_row, start_col = BAYER_RGGB_CHANNEL_LOC_MAP[channel]17 map = np.zeros((height, width), dtype=np.bool if is_bool else np.float32)18 for row in range(height):19 if row % period_length == start_row:20 for col in range(width):21 if col % period_length == start_col:22 map[row][col] = True if is_bool else 123 return map24BayerPatternMask = namedtuple('BayerPattern', ['r', 'g1', 'g2', 'b'])25def get_square_bayer_rggb_pattern_map(resolution, is_bool=False):26 return BayerPatternMask(r=generate_rggb_pattern_map(resolution, resolution, 'r', is_bool=is_bool),27 g1=generate_rggb_pattern_map(resolution, resolution, 'g1', is_bool=is_bool),28 g2=generate_rggb_pattern_map(resolution, resolution, 'g2', is_bool=is_bool),29 b=generate_rggb_pattern_map(resolution, resolution, 'b', is_bool=is_bool))30# RGGB_BAYER_PATTERN_MASK_PRELOAD_RESOLUTIONS = [256, 512, 768, 1024]31RGGB_BAYER_PATTERN_MASK_PRELOAD_RESOLUTIONS = [1024]32RGGB_BAYER_PATTERN_MASK = {}33RGGB_BAYER_PATTERN_BOOLEAN_MASK = {}34for resolution in RGGB_BAYER_PATTERN_MASK_PRELOAD_RESOLUTIONS:35 RGGB_BAYER_PATTERN_MASK[resolution] = get_square_bayer_rggb_pattern_map(resolution, False)36 RGGB_BAYER_PATTERN_BOOLEAN_MASK[resolution] = get_square_bayer_rggb_pattern_map(resolution, True)37# test case only38# if __name__ == "__main__":39# # print(RGGB_BAYER_PATTERN_MASK_256)40# for i in range(0, 1024, 256):41# for j in range(0, 1024, 256):42# print("cropped_%d_%d = dataset_1024.map(lambda _img: safe_crop_to_bounding_box(_img, %d, %d, 256, 256))" % (...
bool.py
Source:bool.py
1# In The Name Of God2# ========================================3# [] File Name : bool.py4#5# [] Creation Date : 12-08-20176#7# [] Created By : Parham Alvani (parham.alvani@gmail.com)8# =======================================9class IsBool:10 def __init__(self, age):11 self.age = age12 def __bool__(self):13 return self.age > 2014is_bool = IsBool(23)15if bool(is_bool) is True:16 print("is_bool.age > 20")17else:18 print("is_bool.age <= 20")19if is_bool:20 print("is_bool.age > 20")21else:22 print("is_bool.age <= 20")...
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!!