


import logging

# standard libraries
import sys

import numpy as np
import pytest  # type: ignore

# Custom/local libraries
from matrix import matrix_operation as matop

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

snake_case__  				=			logging.getLogger()
snake_case__  				=			logging.DEBUG
snake_case__  				=			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							(					lowercase__	:Optional[int]   ,    lowercase__	:str					)							->	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"					)
												__magic_name__					:				Tuple				=   (np.array(lowercase__					) + np.array(lowercase__					)).tolist()
												__magic_name__					:				Optional[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 			__SCREAMING_SNAKE_CASE							(					lowercase__	:int   ,    lowercase__	:List[str]					)							->	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"					)
												__magic_name__					:				str				=   (np.array(lowercase__					) - np.array(lowercase__					)).tolist()
												__magic_name__					:				Optional[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 			__SCREAMING_SNAKE_CASE							(					lowercase__	:Union[str, Any]   ,    lowercase__	:Tuple					)							->	int:
						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"					)
												__magic_name__					:				List[str]				=   (np.matmul(lowercase__   ,    lowercase__					)).tolist()
												__magic_name__					:				str				=   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 			__SCREAMING_SNAKE_CASE							(					)							->	int:
						__magic_name__					:				List[str]				=   (3.5 * np.array(lowercase__					)).tolist()
						__magic_name__					:				str				=   matop.scalar_multiply(lowercase__   ,    3.5					)
						assert theo == act
@pytest.mark.mat_ops
def 			__SCREAMING_SNAKE_CASE							(					)							->	str:
						__magic_name__					:				Dict				=   (np.identity(5					)).tolist()
						__magic_name__					:				int				=   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							(					lowercase__	:Tuple					)							->	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:
												__magic_name__					:				Dict				=   (np.transpose(lowercase__					)).tolist()
												__magic_name__					:				Optional[Any]				=   matop.transpose(lowercase__   ,    return_map=lowercase__					)
												assert theo == act






from __future__ import annotations

from collections.abc import Callable
def 			__SCREAMING_SNAKE_CASE							(					lowercase__	:Callable[[int | float], int | float]   ,    lowercase__	:int | float   ,    lowercase__	:int | float   ,    lowercase__	:int = 1_0_0   ,    )							->	float:
						__magic_name__					:				str				=   x_start
						__magic_name__					:				str				=   fnc(lowercase__					)
						__magic_name__					:				Union[str, Any]				=   0.0

						for _ in range(lowercase__					):
												# Approximates small segments of curve as linear and solve
												# for trapezoidal area
												__magic_name__					:				Optional[int]				=   (x_end - x_start) / steps + xa
												__magic_name__					:				List[Any]				=   fnc(lowercase__					)
												area += abs(fxa + fxa					) * (xa - xa) / 2

												# Increment step
												__magic_name__					:				Optional[Any]				=   xa
												__magic_name__					:				Union[str, Any]				=   fxa
						return area


if __name__ == "__main__":
			def 			__SCREAMING_SNAKE_CASE							(					lowercase__	:Dict					)							->	Optional[int]:
									return x**3

			print('f(x) = x^3')
			print('The area between the curve, x = -10, x = 10 and the x axis is:')
			snake_case__  				=			10
			while i <= 10_0000:
						snake_case__  				=			trapezoidal_area(f, -5, 5, i)
						print(F"""with {i} steps: {area}""")
						i *= 10


