code: 
  
  
  '''simple docstring'''
  
  
  
  
  
  import logging
  
  # standard libraries
  import sys
  
  import numpy as np
  import pytest  # type: ignore
  
  # Custom/local libraries
  from matrix import matrix_operation as matop
  
  UpperCAmelCase__      =							[[1_2, 1_0], [3, 9]]
  UpperCAmelCase__      =							[[3, 4], [7, 4]]
  UpperCAmelCase__      =							[[3, 0, 2], [2, 0, -2], [0, 1, 1]]
  UpperCAmelCase__      =							[[3, 0, -2], [2, 0, 2], [0, 1, 1]]
  UpperCAmelCase__      =							[[3, 0, 2], [2, 0, -2], [0, 1, 1], [2, 0, -2]]
  UpperCAmelCase__      =							[1]
  UpperCAmelCase__      =							[2]
  
  UpperCAmelCase__      =							logging.getLogger()
  UpperCAmelCase__      =							logging.DEBUG
  UpperCAmelCase__      =							logging.StreamHandler(sys.stdout)
  logger.addHandler(stream_handler)
  
  
  
  
  
  
  @pytest.mark.mat_ops
  @pytest.mark.parametrize(
      ('mat1', 'mat2'),[(mat_a, mat_b), (mat_c, mat_d), (mat_d, mat_e), (mat_f, mat_h)]   )
  def 	UpperCAmelCase__(							_SCREAMING_SNAKE_CASE				:   Dict,_SCREAMING_SNAKE_CASE				:   int   ):
  
  
  
  
  
  
  			"""simple docstring"""
  
  
  
  
  			if (np.array(_SCREAMING_SNAKE_CASE   )).shape < (2, 2) or (np.array(_SCREAMING_SNAKE_CASE   )).shape < (2, 2):
  						with pytest.raises(_SCREAMING_SNAKE_CASE   ):
  									logger.info(f"""\n\t{test_addition.__name__} returned integer"""   )
  									matop.add(_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE   )
  			elif (np.array(_SCREAMING_SNAKE_CASE   )).shape == (np.array(_SCREAMING_SNAKE_CASE   )).shape:
  						logger.info(f"""\n\t{test_addition.__name__} with same matrix dims"""   )
  						__A=  (np.array(_SCREAMING_SNAKE_CASE   ) + np.array(_SCREAMING_SNAKE_CASE   )).tolist()
  						__A=  matop.add(_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE   )
  						assert theo == act
  			else:
  						with pytest.raises(_SCREAMING_SNAKE_CASE   ):
  									logger.info(f"""\n\t{test_addition.__name__} with different matrix dims"""   )
  									matop.add(_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE   )
  
  
  
  
  
  
  @pytest.mark.mat_ops
  @pytest.mark.parametrize(
      ('mat1', 'mat2'),[(mat_a, mat_b), (mat_c, mat_d), (mat_d, mat_e), (mat_f, mat_h)]   )
  def 	UpperCAmelCase__(							_SCREAMING_SNAKE_CASE				:   Any,_SCREAMING_SNAKE_CASE				:   str   ):
  
  
  
  
  
  
  			"""simple docstring"""
  
  
  
  
  			if (np.array(_SCREAMING_SNAKE_CASE   )).shape < (2, 2) or (np.array(_SCREAMING_SNAKE_CASE   )).shape < (2, 2):
  						with pytest.raises(_SCREAMING_SNAKE_CASE   ):
  									logger.info(f"""\n\t{test_subtraction.__name__} returned integer"""   )
  									matop.subtract(_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE   )
  			elif (np.array(_SCREAMING_SNAKE_CASE   )).shape == (np.array(_SCREAMING_SNAKE_CASE   )).shape:
  						logger.info(f"""\n\t{test_subtraction.__name__} with same matrix dims"""   )
  						__A=  (np.array(_SCREAMING_SNAKE_CASE   ) - np.array(_SCREAMING_SNAKE_CASE   )).tolist()
  						__A=  matop.subtract(_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE   )
  						assert theo == act
  			else:
  						with pytest.raises(_SCREAMING_SNAKE_CASE   ):
  									logger.info(f"""\n\t{test_subtraction.__name__} with different matrix dims"""   )
  									assert matop.subtract(_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE   )
  
  
  
  
  
  
  @pytest.mark.mat_ops
  @pytest.mark.parametrize(
      ('mat1', 'mat2'),[(mat_a, mat_b), (mat_c, mat_d), (mat_d, mat_e), (mat_f, mat_h)]   )
  def 	UpperCAmelCase__(							_SCREAMING_SNAKE_CASE				:   Tuple,_SCREAMING_SNAKE_CASE				:   Optional[int]   ):
  
  
  
  
  
  
  			"""simple docstring"""
  
  
  
  
  			if (np.array(_SCREAMING_SNAKE_CASE   )).shape < (2, 2) or (np.array(_SCREAMING_SNAKE_CASE   )).shape < (2, 2):
  						logger.info(f"""\n\t{test_multiplication.__name__} returned integer"""   )
  						with pytest.raises(_SCREAMING_SNAKE_CASE   ):
  									matop.add(_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE   )
  			elif (np.array(_SCREAMING_SNAKE_CASE   )).shape == (np.array(_SCREAMING_SNAKE_CASE   )).shape:
  						logger.info(f"""\n\t{test_multiplication.__name__} meets dim requirements"""   )
  						__A=  (np.matmul(_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE   )).tolist()
  						__A=  matop.multiply(_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE   )
  						assert theo == act
  			else:
  						with pytest.raises(_SCREAMING_SNAKE_CASE   ):
  									logger.info(
  									    f"""\n\t{test_multiplication.__name__} does not meet dim requirements"""   )
  									assert matop.subtract(_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE   )
  
  
  
  
  
  
  @pytest.mark.mat_ops
  def 	UpperCAmelCase__(							):
  
  
  
  
  
  
  			"""simple docstring"""
  
  
  
  
  			__A=  (3.5 * np.array(_SCREAMING_SNAKE_CASE   )).tolist()
  			__A=  matop.scalar_multiply(_SCREAMING_SNAKE_CASE,3.5   )
  			assert theo == act
  
  
  
  
  
  
  @pytest.mark.mat_ops
  def 	UpperCAmelCase__(							):
  
  
  
  
  
  
  			"""simple docstring"""
  
  
  
  
  			__A=  (np.identity(5   )).tolist()
  			__A=  matop.identity(5   )
  			assert theo == act
  
  
  
  
  
  
  @pytest.mark.mat_ops
  @pytest.mark.parametrize('mat',[mat_a, mat_b, mat_c, mat_d, mat_e, mat_f]   )
  def 	UpperCAmelCase__(							_SCREAMING_SNAKE_CASE				:   str   ):
  
  
  
  
  
  
  			"""simple docstring"""
  
  
  
  
  			if (np.array(_SCREAMING_SNAKE_CASE   )).shape < (2, 2):
  						with pytest.raises(_SCREAMING_SNAKE_CASE   ):
  									logger.info(f"""\n\t{test_transpose.__name__} returned integer"""   )
  									matop.transpose(_SCREAMING_SNAKE_CASE   )
  			else:
  						__A=  (np.transpose(_SCREAMING_SNAKE_CASE   )).tolist()
  						__A=  matop.transpose(_SCREAMING_SNAKE_CASE,return_map=_SCREAMING_SNAKE_CASE   )
  						assert theo == act
  
  
  
  
style_context: 
  
  
  '''simple docstring'''
  
  
  
  
  
  import numpy as np
  from cva import destroyAllWindows, imread, imshow, waitKey
  class 	a__				:
  
  
  
  
  
  			'''simple docstring'''
  
  			def __init__(     self       : Dict ,						lowerCAmelCase_       : Optional[Any] ,						lowerCAmelCase_       : int  )			->		Optional[int]:
  						__A=  0
  						# max greyscale value for #FFFFFF
  						__A=  int(self.get_greyscale(255 ,						255 ,						255  )  )
  
  						if not self.min_threshold < threshold < self.max_threshold:
  									__A=  F"""Factor value should be from 0 to {self.max_threshold}"""
  									raise ValueError(lowerCAmelCase_  )
  
  						__A=  input_img
  						__A=  threshold
  						__A,  __A=  self.input_img.shape[1], self.input_img.shape[0]
  
  						# error table size (+4 columns and +1 row) greater than input image because of
  						# lack of if statements
  						__A=  [
  						    [0 for _ in range(self.height + 4  )] for __ in range(self.width + 1  )
  						]
  						__A=  np.ones((self.width, self.height, 3) ,						np.uinta  ) * 255
  			@classmethod
  			def 				lowerCAmelCase    (     cls       : Tuple ,						lowerCAmelCase_       : int ,						lowerCAmelCase_       : int ,						lowerCAmelCase_       : int  )			->		float:
  						return 0.1_14 * blue + 0.5_87 * green + 0.21_26 * red
  
  			def 				lowerCAmelCase    (     self       : str  )			->		None:
  						for y in range(self.height  ):
  									for x in range(self.width  ):
  												__A=  int(self.get_greyscale(*self.input_img[y][x]  )  )
  												if self.threshold > greyscale + self.error_table[y][x]:
  															__A=  (0, 0, 0)
  															__A=  greyscale + self.error_table[x][y]
  												else:
  															__A=  (255, 255, 255)
  															__A=  greyscale + self.error_table[x][y] - 255
  												self.error_table[y][x + 1] += int(8 / 32 * current_error  )
  												self.error_table[y][x + 2] += int(4 / 32 * current_error  )
  												self.error_table[y + 1][x] += int(8 / 32 * current_error  )
  												self.error_table[y + 1][x + 1] += int(4 / 32 * current_error  )
  												self.error_table[y + 1][x + 2] += int(2 / 32 * current_error  )
  												self.error_table[y + 1][x - 1] += int(4 / 32 * current_error  )
  												self.error_table[y + 1][x - 2] += int(2 / 32 * current_error  )
  
  
  if __name__ == "__main__":
  					# create Burke's instances with original images in greyscale
  					UpperCAmelCase__      =							[
  					    Burkes(imread('''image_data/lena.jpg''', 1), threshold)
  					    for threshold in (1, 1_2_6, 1_3_0, 1_4_0)
  					]
  
  					for burkes in burkes_instances:
  										burkes.process()
  
  					for burkes in burkes_instances:
  										imshow(
  										    F"""Original image with dithering threshold: {burkes.threshold}""",
  										    burkes.output_img,
  										)
  
  					waitKey(0)
  					destroyAllWindows()
  
  
  
  