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

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

a_     =  logging.getLogger()
a_     =  logging.DEBUG
a_     =  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,						__SCREAMING_SNAKE_CASE    ):
    """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'    )
        snake_case_	:      int            =  (np.array(__SCREAMING_SNAKE_CASE    ) + np.array(__SCREAMING_SNAKE_CASE    )).tolist()
        snake_case_	:      Dict            =  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,						__SCREAMING_SNAKE_CASE    ):
    """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'    )
        snake_case_	:      List[Any]            =  (np.array(__SCREAMING_SNAKE_CASE    ) - np.array(__SCREAMING_SNAKE_CASE    )).tolist()
        snake_case_	:      Dict            =  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,						__SCREAMING_SNAKE_CASE    ):
    """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'    )
        snake_case_	:      int            =  (np.matmul(__SCREAMING_SNAKE_CASE,						__SCREAMING_SNAKE_CASE    )).tolist()
        snake_case_	:      Optional[Any]            =  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"""






    snake_case_	:      Any            =  (3.5 * np.array(__SCREAMING_SNAKE_CASE    )).tolist()
    snake_case_	:      Optional[int]            =  matop.scalar_multiply(__SCREAMING_SNAKE_CASE,						3.5    )
    assert theo == act

@pytest.mark.mat_ops
def   UpperCamelCase_       (		):
    """simple docstring"""






    snake_case_	:      Any            =  (np.identity(5    )).tolist()
    snake_case_	:      Optional[Any]            =  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    ):
    """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:
        snake_case_	:      List[Any]            =  (np.transpose(__SCREAMING_SNAKE_CASE    )).tolist()
        snake_case_	:      Any            =  matop.transpose(__SCREAMING_SNAKE_CASE,						return_map=__SCREAMING_SNAKE_CASE    )
        assert theo == act






'''simple docstring'''
from __future__ import annotations

from typing import Any






class 				UpperCAmelCase_			:





 def __init__(      self	,    lowercase_	,    lowercase_):  # noqa: A002
     snake_case_	:      List[str]            =  item
     snake_case_	:      Dict            =  next






class 				UpperCAmelCase_			:





 def __init__(      self):
     snake_case_	:      Node | None            =  None
     snake_case_	:      List[str]            =  0





 def     snake_case__						(      self	,    lowercase_):
     snake_case_	:      List[Any]            =  Node(lowercase_	,    self.head)
     self.size += 1





 def     snake_case__						(      self):
     # Switched 'self.is_empty()' to 'self.head is None'
     # because mypy was considering the possibility that 'self.head'
     # can be None in below else part and giving error
     if self.head is None:
         return None
     else:
         snake_case_	:      List[Any]            =  self.head.item
         snake_case_	:      Any            =  self.head.next
         self.size -= 1
         return item





 def     snake_case__						(      self):
     return self.head is None





 def __str__(      self):
     if self.is_empty():
         return ""
     else:
         snake_case_	:      Dict            =  self.head
         snake_case_	:      Optional[Any]            =  ""
         snake_case_	:      list[str]            =  []
         while iterate:
             item_list.append(str(iterate.item))
             snake_case_	:      List[str]            =  iterate.next

         snake_case_	:      Optional[Any]            =  " --> ".join(lowercase_)

         return item_str





 def __len__(      self):
     return self.size




