

import logging

# standard libraries
import sys

import numpy as np
import pytest  # type: ignore

# Custom/local libraries
from matrix import matrix_operation as matop

lowerCamelCase     =      [[12, 10], [3, 9]]
lowerCamelCase     =      [[3, 4], [7, 4]]
lowerCamelCase     =      [[3, 0, 2], [2, 0, -2], [0, 1, 1]]
lowerCamelCase     =      [[3, 0, -2], [2, 0, 2], [0, 1, 1]]
lowerCamelCase     =      [[3, 0, 2], [2, 0, -2], [0, 1, 1], [2, 0, -2]]
lowerCamelCase     =      [1]
lowerCamelCase     =      [2]

lowerCamelCase     =      logging.getLogger()
lowerCamelCase     =      logging.DEBUG
lowerCamelCase     =      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__       (    _A   :				List[Any]			,   _A   :				Union[str, Any]							):





  '''simple docstring'''







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




@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__       (    _A   :				Optional[Any]			,   _A   :				List[str]							):





  '''simple docstring'''







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




@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__       (    _A   :				Any			,   _A   :				Union[str, Any]							):





  '''simple docstring'''







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




@pytest.mark.mat_ops
def     UpperCAmelCase__       (    ):





  '''simple docstring'''







  a__						=(3.5 * np.array(_A							)).tolist()
  a__						=matop.scalar_multiply(_A			,   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__       (    _A   :				Optional[Any]							):





  '''simple docstring'''







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



import heapq




def     UpperCAmelCase__       (    _A   :				Optional[Any]			,   _A   :				str			,   _A   :				Optional[Any]							):





  '''simple docstring'''







  a__						=[(0, start)]  # cost from start node,end node
  a__						=set()
  while heap:
    ((a__),   (a__))						=heapq.heappop(_A							)
    if u in visited:
      continue
    visited.add(_A							)
    if u == end:
      return cost
    for v, c in graph[u]:
      if v in visited:
        continue
      a__						=cost + c
      heapq.heappush(_A			,   (next_item, v)							)
  return -1


lowerCamelCase     =      {
    '''A''': [['''B''', 2], ['''C''', 5]],
    '''B''': [['''A''', 2], ['''D''', 3], ['''E''', 1], ['''F''', 1]],
    '''C''': [['''A''', 5], ['''F''', 3]],
    '''D''': [['''B''', 3]],
    '''E''': [['''B''', 4], ['''F''', 3]],
    '''F''': [['''C''', 3], ['''E''', 3]],
}
lowerCamelCase     =      {
    '''B''': [['''C''', 1]],
    '''C''': [['''D''', 1]],
    '''D''': [['''F''', 1]],
    '''E''': [['''B''', 1], ['''F''', 3]],
    '''F''': [],
}
lowerCamelCase     =      {
    '''B''': [['''C''', 1]],
    '''C''': [['''D''', 1]],
    '''D''': [['''F''', 1]],
    '''E''': [['''B''', 1], ['''G''', 2]],
    '''F''': [],
    '''G''': [['''F''', 1]],
}

lowerCamelCase     =      dijkstra(G, '''E''', '''C''')
print(short_distance)  # E -- 3 --> F -- 3 --> C == 6

lowerCamelCase     =      dijkstra(Ga, '''E''', '''F''')
print(short_distance)  # E -- 3 --> F == 3

lowerCamelCase     =      dijkstra(Ga, '''E''', '''F''')
print(short_distance)  # E -- 2 --> G -- 1 --> F == 3

if __name__ == "__main__":
       import doctest

       doctest.testmod()
