



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

a  :     Any       =       logging.getLogger()
a  :     Any       =       logging.DEBUG
a  :     str       =       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    (   _lowercase      ,							_lowercase						) ->     Optional[Any]:
							if (np.array(_lowercase						)).shape < (2, 2) or (np.array(_lowercase						)).shape < (2, 2):
														with pytest.raises(_lowercase						):
																					logger.info(F'''\n\t{test_addition.__name__} returned integer'''						)
																					matop.add(_lowercase      ,							_lowercase						)
							elif (np.array(_lowercase						)).shape == (np.array(_lowercase						)).shape:
														logger.info(F'''\n\t{test_addition.__name__} with same matrix dims'''						)
														UpperCAmelCase	:						Optional[Any]					=						(np.array(_lowercase						) + np.array(_lowercase						)).tolist()
														UpperCAmelCase	:						Any					=						matop.add(_lowercase      ,							_lowercase						)
														assert theo == act
							else:
														with pytest.raises(_lowercase						):
																					logger.info(F'''\n\t{test_addition.__name__} with different matrix dims'''						)
																					matop.add(_lowercase      ,							_lowercase						)



@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    (   _lowercase      ,							_lowercase						) ->     Optional[Any]:
							if (np.array(_lowercase						)).shape < (2, 2) or (np.array(_lowercase						)).shape < (2, 2):
														with pytest.raises(_lowercase						):
																					logger.info(F'''\n\t{test_subtraction.__name__} returned integer'''						)
																					matop.subtract(_lowercase      ,							_lowercase						)
							elif (np.array(_lowercase						)).shape == (np.array(_lowercase						)).shape:
														logger.info(F'''\n\t{test_subtraction.__name__} with same matrix dims'''						)
														UpperCAmelCase	:						int					=						(np.array(_lowercase						) - np.array(_lowercase						)).tolist()
														UpperCAmelCase	:						int					=						matop.subtract(_lowercase      ,							_lowercase						)
														assert theo == act
							else:
														with pytest.raises(_lowercase						):
																					logger.info(F'''\n\t{test_subtraction.__name__} with different matrix dims'''						)
																					assert matop.subtract(_lowercase      ,							_lowercase						)



@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    (   _lowercase      ,							_lowercase						) ->     List[Any]:
							if (np.array(_lowercase						)).shape < (2, 2) or (np.array(_lowercase						)).shape < (2, 2):
														logger.info(F'''\n\t{test_multiplication.__name__} returned integer'''						)
														with pytest.raises(_lowercase						):
																					matop.add(_lowercase      ,							_lowercase						)
							elif (np.array(_lowercase						)).shape == (np.array(_lowercase						)).shape:
														logger.info(F'''\n\t{test_multiplication.__name__} meets dim requirements'''						)
														UpperCAmelCase	:						Any					=						(np.matmul(_lowercase      ,							_lowercase						)).tolist()
														UpperCAmelCase	:						Tuple					=						matop.multiply(_lowercase      ,							_lowercase						)
														assert theo == act
							else:
														with pytest.raises(_lowercase						):
																					logger.info(
																					    F'''\n\t{test_multiplication.__name__} does not meet dim requirements'''						)
																					assert matop.subtract(_lowercase      ,							_lowercase						)



@pytest.mark.mat_ops
def  __lowerCamelCase    (   ) ->     Union[str, Any]:
							UpperCAmelCase	:						int					=						(3.5 * np.array(_lowercase						)).tolist()
							UpperCAmelCase	:						int					=						matop.scalar_multiply(_lowercase      ,							3.5						)
							assert theo == act



@pytest.mark.mat_ops
def  __lowerCamelCase    (   ) ->     Tuple:
							UpperCAmelCase	:						Union[str, Any]					=						(np.identity(5						)).tolist()
							UpperCAmelCase	:						Tuple					=						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    (   _lowercase						) ->     List[str]:
							if (np.array(_lowercase						)).shape < (2, 2):
														with pytest.raises(_lowercase						):
																					logger.info(F'''\n\t{test_transpose.__name__} returned integer'''						)
																					matop.transpose(_lowercase						)
							else:
														UpperCAmelCase	:						Optional[int]					=						(np.transpose(_lowercase						)).tolist()
														UpperCAmelCase	:						Dict					=						matop.transpose(_lowercase      ,							return_map=_lowercase						)
														assert theo == act






'''simple docstring'''




class      UpperCamelCase_					:





	def __init__(    self       )     ->     None:
								UpperCAmelCase	:						int					=						[0, 1]






	def 					_lowercase(    self						,						A       )     ->     list:
								if (difference := index - (len(self.sequence       ) - 2)) >= 1:
															for _ in range(A       ):
																						self.sequence.append(self.sequence[-1] + self.sequence[-2]       )
								return self.sequence[:index]




def  __lowerCamelCase    (   ) ->     None:
							print(
							    """Fibonacci Series Using Dynamic Programming\n"""      ,							"""Enter the index of the Fibonacci number you want to calculate """      ,							"""in the prompt below. (To exit enter exit or Ctrl-C)\n"""      ,							sep=""""""      ,							)
							UpperCAmelCase	:						Tuple					=						Fibonacci()

							while True:
														UpperCAmelCase	:						str					=						input(""">> """						)
														if prompt in {"exit", "quit"}:
																					break

														try:
																					UpperCAmelCase	:						int					=						int(_lowercase						)
														except ValueError:
																					print("""Enter a number or 'exit'"""						)
																					continue

														print(fibonacci.get(_lowercase						)						)


if __name__ == "__main__":
							main()

