




import logging

# standard libraries
import sys

import numpy as np
import pytest  # type: ignore

# Custom/local libraries
from matrix import matrix_operation as matop

__SCREAMING_SNAKE_CASE      :				Dict				      =[[12, 10], [3, 9]]
__SCREAMING_SNAKE_CASE      :				Optional[Any]				      =[[3, 4], [7, 4]]
__SCREAMING_SNAKE_CASE      :				Tuple				      =[[3, 0, 2], [2, 0, -2], [0, 1, 1]]
__SCREAMING_SNAKE_CASE      :				List[str]				      =[[3, 0, -2], [2, 0, 2], [0, 1, 1]]
__SCREAMING_SNAKE_CASE      :				int				      =[[3, 0, 2], [2, 0, -2], [0, 1, 1], [2, 0, -2]]
__SCREAMING_SNAKE_CASE      :				List[str]				      =[1]
__SCREAMING_SNAKE_CASE      :				Dict				      =[2]

__SCREAMING_SNAKE_CASE      :				Any				      =logging.getLogger()
__SCREAMING_SNAKE_CASE      :				Any				      =logging.DEBUG
__SCREAMING_SNAKE_CASE      :				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      lowerCAmelCase_     (					lowerCamelCase:    List[str]       ,			lowerCamelCase:    Optional[Any]  )   ->     List[Any]:


      '''simple docstring'''




      if (np.array(lowerCamelCase  )).shape < (2, 2) or (np.array(lowerCamelCase  )).shape < (2, 2):
            with pytest.raises(lowerCamelCase  ):
                  logger.info(f"""\n\t{test_addition.__name__} returned integer"""  )
                  matop.add(lowerCamelCase       ,			lowerCamelCase  )
      elif (np.array(lowerCamelCase  )).shape == (np.array(lowerCamelCase  )).shape:
            logger.info(f"""\n\t{test_addition.__name__} with same matrix dims"""  )
            lowerCamelCase__ 					=			(np.array(lowerCamelCase  ) + np.array(lowerCamelCase  )).tolist()
            lowerCamelCase__ 					=			matop.add(lowerCamelCase       ,			lowerCamelCase  )
            assert theo == act
      else:
            with pytest.raises(lowerCamelCase  ):
                  logger.info(f"""\n\t{test_addition.__name__} with different matrix dims"""  )
                  matop.add(lowerCamelCase       ,			lowerCamelCase  )

@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      lowerCAmelCase_     (					lowerCamelCase:    Optional[int]       ,			lowerCamelCase:    Any  )   ->     Optional[int]:


      '''simple docstring'''




      if (np.array(lowerCamelCase  )).shape < (2, 2) or (np.array(lowerCamelCase  )).shape < (2, 2):
            with pytest.raises(lowerCamelCase  ):
                  logger.info(f"""\n\t{test_subtraction.__name__} returned integer"""  )
                  matop.subtract(lowerCamelCase       ,			lowerCamelCase  )
      elif (np.array(lowerCamelCase  )).shape == (np.array(lowerCamelCase  )).shape:
            logger.info(f"""\n\t{test_subtraction.__name__} with same matrix dims"""  )
            lowerCamelCase__ 					=			(np.array(lowerCamelCase  ) - np.array(lowerCamelCase  )).tolist()
            lowerCamelCase__ 					=			matop.subtract(lowerCamelCase       ,			lowerCamelCase  )
            assert theo == act
      else:
            with pytest.raises(lowerCamelCase  ):
                  logger.info(f"""\n\t{test_subtraction.__name__} with different matrix dims"""  )
                  assert matop.subtract(lowerCamelCase       ,			lowerCamelCase  )

@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      lowerCAmelCase_     (					lowerCamelCase:    str       ,			lowerCamelCase:    List[Any]  )   ->     Dict:


      '''simple docstring'''




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

@pytest.mark.mat_ops
def      lowerCAmelCase_     (					)   ->     Optional[int]:


      '''simple docstring'''




      lowerCamelCase__ 					=			(3.5 * np.array(lowerCamelCase  )).tolist()
      lowerCamelCase__ 					=			matop.scalar_multiply(lowerCamelCase       ,			3.5  )
      assert theo == act

@pytest.mark.mat_ops
def      lowerCAmelCase_     (					)   ->     Tuple:


      '''simple docstring'''




      lowerCamelCase__ 					=			(np.identity(5  )).tolist()
      lowerCamelCase__ 					=			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      lowerCAmelCase_     (					lowerCamelCase:    str  )   ->     Union[str, Any]:


      '''simple docstring'''




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





def      lowerCAmelCase_     (					lowerCamelCase:    list       ,			lowerCamelCase:    int       ,			lowerCamelCase:    int  )   ->     None:


      '''simple docstring'''




      if right <= left:
            return
      lowerCamelCase__ 					=			lowerCamelCase__ 					=			left
      lowerCamelCase__ 					=			right
      lowerCamelCase__ 					=			sorting[left]
      while i <= b:
            if sorting[i] < pivot:
                  lowerCamelCase__					,						lowerCamelCase__ 					=			sorting[i], sorting[a]
                  a += 1
                  i += 1
            elif sorting[i] > pivot:
                  lowerCamelCase__					,						lowerCamelCase__ 					=			sorting[i], sorting[b]
                  b -= 1
            else:
                  i += 1
      quick_sort_apartition(lowerCamelCase       ,			lowerCamelCase       ,			a - 1  )
      quick_sort_apartition(lowerCamelCase       ,			b + 1       ,			lowerCamelCase  )

def      lowerCAmelCase_     (					lowerCamelCase:    list       ,			lowerCamelCase:    int       ,			lowerCamelCase:    int  )   ->     None:


      '''simple docstring'''




      if left < right:
            lowerCamelCase__ 					=			lomuto_partition(lowerCamelCase       ,			lowerCamelCase       ,			lowerCamelCase  )
            quick_sort_lomuto_partition(lowerCamelCase       ,			lowerCamelCase       ,			pivot_index - 1  )
            quick_sort_lomuto_partition(lowerCamelCase       ,			pivot_index + 1       ,			lowerCamelCase  )

def      lowerCAmelCase_     (					lowerCamelCase:    list       ,			lowerCamelCase:    int       ,			lowerCamelCase:    int  )   ->     int:


      '''simple docstring'''




      lowerCamelCase__ 					=			sorting[right]
      lowerCamelCase__ 					=			left
      for i in range(lowerCamelCase       ,			lowerCamelCase  ):
            if sorting[i] < pivot:
                  lowerCamelCase__					,						lowerCamelCase__ 					=			sorting[i], sorting[store_index]
                  store_index += 1
      lowerCamelCase__					,						lowerCamelCase__ 					=			sorting[store_index], sorting[right]
      return store_index

def      lowerCAmelCase_     (					lowerCamelCase:    list  )   ->     list:


      '''simple docstring'''




      if len(lowerCamelCase  ) <= 1:
            return sorting
      return (
          three_way_radix_quicksort([i for i in sorting if i < sorting[0]]  )
          + [i for i in sorting if i == sorting[0]]
          + three_way_radix_quicksort([i for i in sorting if i > sorting[0]]  )
      )


if __name__ == "__main__":
      import doctest

      doctest.testmod(verbose=True)

      __SCREAMING_SNAKE_CASE      :				Optional[int]				      =input("""Enter numbers separated by a comma:\n""").strip()
      __SCREAMING_SNAKE_CASE      :				str				      =[int(item) for item in user_input.split(""",""")]
      quick_sort_apartition(unsorted, 0, len(unsorted) - 1)
      print(unsorted)