


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__            =							[[12, 10], [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_ (							__snake_case					,						__snake_case						)					->      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     UpperCAmelCase_ (							__snake_case					,						__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_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     UpperCAmelCase_ (							__snake_case					,						__snake_case						)					->      Union[str, Any]:







 """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     UpperCAmelCase_ (							)					->      List[Any]:







 """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     UpperCAmelCase_ (							)					->      int:







 """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     UpperCAmelCase_ (							__snake_case						)					->      List[Any]:







 """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




UpperCAmelCase__            =							[
    [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
    [0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0],
    [0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0],
]
def     UpperCAmelCase_ (							__snake_case					,						__snake_case					,						__snake_case					,						__snake_case						)					->      bool:







 """simple docstring"""


 return 0 <= row < rows and 0 <= col < cols
def     UpperCAmelCase_ (							__snake_case					,						__snake_case					,						__snake_case					,						__snake_case						)					->      int:







 """simple docstring"""


 _lowercase											=len(__snake_case						)
 _lowercase											=len(mat[0]						)
 if is_safe(__snake_case					,						__snake_case					,						__snake_case					,						__snake_case						) and (row, col) not in seen and mat[row][col] == 1:
  seen.add((row, col)						)
  return (
      1
      + depth_first_search(row + 1					,						__snake_case					,						__snake_case					,						__snake_case						)
      + depth_first_search(row - 1					,						__snake_case					,						__snake_case					,						__snake_case						)
      + depth_first_search(__snake_case					,						col + 1					,						__snake_case					,						__snake_case						)
      + depth_first_search(__snake_case					,						col - 1					,						__snake_case					,						__snake_case						)
  )
 else:
  return 0
def     UpperCAmelCase_ (							__snake_case						)					->      int:







 """simple docstring"""


 _lowercase											=set()

 _lowercase											=0
 for row, line in enumerate(__snake_case						):
  for col, item in enumerate(__snake_case						):
   if item == 1 and (row, col) not in seen:
    # Maximizing the area
    _lowercase											=max(__snake_case					,						depth_first_search(__snake_case					,						__snake_case					,						__snake_case					,						__snake_case						)						)
 return max_area


if __name__ == "__main__":
  import doctest

  print(find_max_area(matrix))  # Output -> 6
  doctest.testmod()

