


"""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 					a__ (       _UpperCamelCase	,			_UpperCamelCase ):





						"""simple docstring"""

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






@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 					a__ (       _UpperCamelCase	,			_UpperCamelCase ):





						"""simple docstring"""

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






@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 					a__ (       _UpperCamelCase	,			_UpperCamelCase ):





						"""simple docstring"""

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






@pytest.mark.mat_ops
def 					a__ (       ):





						"""simple docstring"""

						UpperCAmelCase__		=    (3.5 * np.array(_UpperCamelCase )).tolist()
						UpperCAmelCase__		=    matop.scalar_multiply(_UpperCamelCase	,			3.5 )
						assert theo == act






@pytest.mark.mat_ops
def 					a__ (       ):





						"""simple docstring"""

						UpperCAmelCase__		=    (np.identity(5 )).tolist()
						UpperCAmelCase__		=    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 					a__ (       _UpperCamelCase ):





						"""simple docstring"""

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



"""simple docstring"""







from __future__ import annotations

from collections.abc import Callable






def 					a__ (       _UpperCamelCase	,			_UpperCamelCase	,			_UpperCamelCase	,			_UpperCamelCase = 100	,			):





						"""simple docstring"""

						UpperCAmelCase__		=    x_start
						UpperCAmelCase__		=    fnc(_UpperCamelCase )
						UpperCAmelCase__		=    0.0

						for _ in range(_UpperCamelCase ):
												# Approximates small segments of curve as linear and solve
												# for trapezoidal area
												UpperCAmelCase__		=    (x_end - x_start) / steps + xa
												UpperCAmelCase__		=    fnc(_UpperCamelCase )
												area += abs(fxa + fxa ) * (xa - xa) / 2

												# Increment step
												UpperCAmelCase__		=    xa
												UpperCAmelCase__		=    fxa
						return area


if __name__ == "__main__":






						def 					a__ (       _UpperCamelCase ):





												"""simple docstring"""

												return x**3

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