






"""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						:    str		=						[[1_2, 1_0], [3, 9]]
_UpperCamelCase						:    Any		=						[[3, 4], [7, 4]]
_UpperCamelCase						:    Any		=						[[3, 0, 2], [2, 0, -2], [0, 1, 1]]
_UpperCamelCase						:    int		=						[[3, 0, -2], [2, 0, 2], [0, 1, 1]]
_UpperCamelCase						:    List[str]		=						[[3, 0, 2], [2, 0, -2], [0, 1, 1], [2, 0, -2]]
_UpperCamelCase						:    Dict		=						[1]
_UpperCamelCase						:    int		=						[2]

_UpperCamelCase						:    Optional[int]		=						logging.getLogger()
_UpperCamelCase						:    Any		=						logging.DEBUG
_UpperCamelCase						:    Optional[int]		=						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 		_SCREAMING_SNAKE_CASE					(       __snake_case     :    int						,   __snake_case     :    Union[str, Any]       ):





  '''simple docstring'''





  if (np.array(__snake_case       )).shape < (2, 2) or (np.array(__snake_case       )).shape < (2, 2):
    with pytest.raises(__snake_case       ):
      logger.info(f'\n\t{test_addition.__name__} returned integer'       )
      matop.add(__snake_case						,   __snake_case       )
  elif (np.array(__snake_case       )).shape == (np.array(__snake_case       )).shape:
    logger.info(f'\n\t{test_addition.__name__} with same matrix dims'       )
    lowercase				       =			(np.array(__snake_case       ) + np.array(__snake_case       )).tolist()
    lowercase				       =			matop.add(__snake_case						,   __snake_case       )
    assert theo == act
  else:
    with pytest.raises(__snake_case       ):
      logger.info(f'\n\t{test_addition.__name__} with different matrix dims'       )
      matop.add(__snake_case						,   __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 		_SCREAMING_SNAKE_CASE					(       __snake_case     :    Tuple						,   __snake_case     :    Optional[Any]       ):





  '''simple docstring'''





  if (np.array(__snake_case       )).shape < (2, 2) or (np.array(__snake_case       )).shape < (2, 2):
    with pytest.raises(__snake_case       ):
      logger.info(f'\n\t{test_subtraction.__name__} returned integer'       )
      matop.subtract(__snake_case						,   __snake_case       )
  elif (np.array(__snake_case       )).shape == (np.array(__snake_case       )).shape:
    logger.info(f'\n\t{test_subtraction.__name__} with same matrix dims'       )
    lowercase				       =			(np.array(__snake_case       ) - np.array(__snake_case       )).tolist()
    lowercase				       =			matop.subtract(__snake_case						,   __snake_case       )
    assert theo == act
  else:
    with pytest.raises(__snake_case       ):
      logger.info(f'\n\t{test_subtraction.__name__} with different matrix dims'       )
      assert matop.subtract(__snake_case						,   __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 		_SCREAMING_SNAKE_CASE					(       __snake_case     :    Dict						,   __snake_case     :    int       ):





  '''simple docstring'''





  if (np.array(__snake_case       )).shape < (2, 2) or (np.array(__snake_case       )).shape < (2, 2):
    logger.info(f'\n\t{test_multiplication.__name__} returned integer'       )
    with pytest.raises(__snake_case       ):
      matop.add(__snake_case						,   __snake_case       )
  elif (np.array(__snake_case       )).shape == (np.array(__snake_case       )).shape:
    logger.info(f'\n\t{test_multiplication.__name__} meets dim requirements'       )
    lowercase				       =			(np.matmul(__snake_case						,   __snake_case       )).tolist()
    lowercase				       =			matop.multiply(__snake_case						,   __snake_case       )
    assert theo == act
  else:
    with pytest.raises(__snake_case       ):
      logger.info(
          f'\n\t{test_multiplication.__name__} does not meet dim requirements'       )
      assert matop.subtract(__snake_case						,   __snake_case       )
@pytest.mark.mat_ops
def 		_SCREAMING_SNAKE_CASE					(       ):





  '''simple docstring'''





  lowercase				       =			(3.5 * np.array(__snake_case       )).tolist()
  lowercase				       =			matop.scalar_multiply(__snake_case						,   3.5       )
  assert theo == act
@pytest.mark.mat_ops
def 		_SCREAMING_SNAKE_CASE					(       ):





  '''simple docstring'''





  lowercase				       =			(np.identity(5       )).tolist()
  lowercase				       =			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 		_SCREAMING_SNAKE_CASE					(       __snake_case     :    str       ):





  '''simple docstring'''





  if (np.array(__snake_case       )).shape < (2, 2):
    with pytest.raises(__snake_case       ):
      logger.info(f'\n\t{test_transpose.__name__} returned integer'       )
      matop.transpose(__snake_case       )
  else:
    lowercase				       =			(np.transpose(__snake_case       )).tolist()
    lowercase				       =			matop.transpose(__snake_case						,   return_map=__snake_case       )
    assert theo == act






__lowerCamelCase   	=  {0: [1, 2], 1: [0, 3], 2: [0], 3: [1], 4: [5, 6], 5: [4, 6], 6: [4, 5]}

__lowerCamelCase   	=  {0: [1, 2, 3], 1: [0, 3], 2: [0], 3: [0, 1], 4: [], 5: []}



def 			_a      (    __UpperCamelCase	,	__UpperCamelCase	,	__UpperCamelCase			):
     a_     :  Tuple				      =     True
     a_     :  Optional[Any]				      =     []

     for neighbour in graph[vert]:
          if not visited[neighbour]:
               connected_verts += dfs(__UpperCamelCase	,	__UpperCamelCase	,	__UpperCamelCase			)

     return [vert, *connected_verts]



def 			_a      (    __UpperCamelCase			):
     a_     :  Dict				      =     len(__UpperCamelCase			)
     a_     :  List[str]				      =     graph_size * [False]
     a_     :  Dict				      =     []

     for i in range(__UpperCamelCase			):
          if not visited[i]:
               a_     :  str				      =     dfs(__UpperCamelCase	,	__UpperCamelCase	,	__UpperCamelCase			)
               components_list.append(__UpperCamelCase			)

     return components_list


if __name__ == "__main__":
       import doctest

       doctest.testmod()



