






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

_UpperCamelCase						:    str		=						[[1_2, 1_0], [3, 9]]
_UpperCamelCase						:    Any		=						[[3, 4], [7, 4]]
_UpperCamelCase						:    Any		=						[[3, 0, 2], [2, 0, -2], [0, 1, 1]]
_UpperCamelCase						:    int		=						[[3, 0, -2], [2, 0, 2], [0, 1, 1]]
_UpperCamelCase						:    List[str]		=						[[3, 0, 2], [2, 0, -2], [0, 1, 1], [2, 0, -2]]
_UpperCamelCase						:    Dict		=						[1]
_UpperCamelCase						:    int		=						[2]

_UpperCamelCase						:    Optional[int]		=						logging.getLogger()
_UpperCamelCase						:    Any		=						logging.DEBUG
_UpperCamelCase						:    Optional[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 		_SCREAMING_SNAKE_CASE					(       __snake_case     :    int						,   __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_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 		_SCREAMING_SNAKE_CASE					(       __snake_case     :    Tuple						,   __snake_case     :    Optional[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 		_SCREAMING_SNAKE_CASE					(       __snake_case     :    Dict						,   __snake_case     :    int       ):





  '''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 		_SCREAMING_SNAKE_CASE					(       ):





  '''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 		_SCREAMING_SNAKE_CASE					(       ):





  '''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 		_SCREAMING_SNAKE_CASE					(       __snake_case     :    str       ):





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




from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier

# Load iris file
lowerCamelCase__        =						load_iris()
iris.keys()


print(F"""Target names: \n {iris.target_names} """)
print(F"""\n Features: \n {iris.feature_names}""")

# Train set e Test set
lowerCamelCase__ ,   lowerCamelCase__ ,   lowerCamelCase__ ,   lowerCamelCase__        =						train_test_split(
    iris["""data"""], iris["""target"""], random_state=4
)

# KNN

lowerCamelCase__        =						KNeighborsClassifier(n_neighbors=1)
knn.fit(X_train, y_train)

# new array to test
lowerCamelCase__        =						[[1, 2, 1, 4], [2, 3, 4, 5]]

lowerCamelCase__        =						knn.predict(X_new)

print(
    F"""\nNew array: \n {X_new}\n\nTarget Names Prediction: \n"""
    F""" {iris["target_names"][prediction]}"""
)