# Path: skrf/mathFunctions.py
# def complex_2_magnitude(z: NumberLike):
# def complex_2_db(z: NumberLike):
# def complex_2_db10(z: NumberLike):
# def complex_2_radian(z: NumberLike):
# def complex_2_degree(z: NumberLike):
# def complex_2_quadrature(z: NumberLike):
# def complex_2_reim(z: NumberLike):
# def complex_components(z: NumberLike):
# def magnitude_2_db(z: NumberLike, zero_nan: bool = True):
# def mag_2_db10(z: NumberLike, zero_nan:bool = True):
# def db_2_magnitude(z: NumberLike):
# def db10_2_mag(z: NumberLike):
# def magdeg_2_reim(mag: NumberLike, deg: NumberLike):
# def dbdeg_2_reim(db: NumberLike, deg: NumberLike):
# def db_2_np(db: NumberLike):
# def np_2_db(x: NumberLike):
# def radian_2_degree(rad: NumberLike):
# def degree_2_radian(deg: NumberLike):
# def feet_2_meter(feet: NumberLike = 1):
# def meter_2_feet(meter: NumberLike = 1):
# def db_per_100feet_2_db_per_100meter(db_per_100feet: NumberLike = 1):
# def unwrap_rad(phi: NumberLike):
# def sqrt_known_sign(z_squared: NumberLike, z_approx: NumberLike):
# def find_correct_sign(z1: NumberLike, z2: NumberLike, z_approx: NumberLike):
# def find_closest(z1: NumberLike, z2: NumberLike, z_approx: NumberLike):
# def sqrt_phase_unwrap(z: NumberLike):
# def dirac_delta(x: NumberLike):
# def neuman(x: NumberLike):
# def null(A: npy.ndarray, eps: float = 1e-15):
# def inf_to_num(x: NumberLike):
# def cross_ratio(a: NumberLike, b: NumberLike, c: NumberLike, d:NumberLike):
# def complexify(f: Callable, name: str = None):
#     def f_c(z, *args, **kw):
# def complex2Scalar(z: NumberLike):
# def scalar2Complex(s: NumberLike):
# def flatten_c_mat(s: NumberLike, order: str = 'F'):
# def rand_c(*args) -> npy.ndarray:
# def psd2TimeDomain(f: npy.ndarray, y: npy.ndarray, windowType: str = 'hamming'):
# def rational_interp(x: npy.ndarray, y: npy.ndarray, d: int = 4, epsilon: float = 1e-9, axis: int = 0, assume_sorted: bool = False) -> Callable:
#     def fx(xi):
# def ifft(x: npy.ndarray) -> npy.ndarray:
# def irfft(x: npy.ndarray, n:int = None) -> npy.ndarray:
# def is_square(mat: npy.ndarray) -> bool:
# def is_unitary(mat: npy.ndarray, tol: float = ALMOST_ZERO) -> bool:
# def is_symmetric(mat: npy.ndarray, tol: int = ALMOST_ZERO) -> bool:
# def get_Hermitian_transpose(mat: npy.ndarray) -> npy.ndarray:
# def is_Hermitian(mat: npy.ndarray, tol: float = ALMOST_ZERO) -> bool:
# def is_positive_definite(mat: npy.ndarray, tol: float = ALMOST_ZERO) -> bool:
# def is_positive_semidefinite(mat: npy.ndarray, tol: float = ALMOST_ZERO) -> bool:
#     T = 1./df


from skrf.mathFunctions import LOG_OF_NEG
from numpy import e, log, pi, isnan, inf
from numpy.testing import assert_equal, run_module_suite, assert_almost_equal
import skrf as rf
import unittest
import numpy as np
        """
        Test complex to quadrature conversion with:
            2, pi  = abs(2j), angle(2j) * abs(2j) 
        """
        assert_almost_equal(rf.complex_2_quadrature(0+2j), (2, pi))


    def test_complex_components(self):
        """
        Test complex components:
        """
        assert_almost_equal(rf.complex_components(0+2j), (0, 2, 90, 2, pi))


    def test_complex_2_reim(self):
        """
        Test complex to (real, imag) conversion:
        """
        assert_almost_equal(rf.complex_2_reim(1+2j), (1,2))


    def test_magnitude_2_db(self):
        """
        Test magnitude to db conversion
        """
        assert_almost_equal(rf.magnitude_2_db(10, True), 20)
        assert_almost_equal(rf.magnitude_2_db(10, False), 20)

        assert_almost_equal(rf.magnitude_2_db(0), -inf)
        assert_almost_equal(rf.magnitude_2_db(-1, True), LOG_OF_NEG)

# Path: skrf/mathFunctions.py
# def complex_2_magnitude(z: NumberLike):
# def complex_2_db(z: NumberLike):
# def complex_2_db10(z: NumberLike):
# def complex_2_radian(z: NumberLike):
# def complex_2_degree(z: NumberLike):
# def complex_2_quadrature(z: NumberLike):
# def complex_2_reim(z: NumberLike):
# def complex_components(z: NumberLike):
# def magnitude_2_db(z: NumberLike, zero_nan: bool = True):
# def mag_2_db10(z: NumberLike, zero_nan:bool = True):
# def db_2_magnitude(z: NumberLike):
# def db10_2_mag(z: NumberLike):
# def magdeg_2_reim(mag: NumberLike, deg: NumberLike):
# def dbdeg_2_reim(db: NumberLike, deg: NumberLike):
# def db_2_np(db: NumberLike):
# def np_2_db(x: NumberLike):
# def radian_2_degree(rad: NumberLike):
# def degree_2_radian(deg: NumberLike):
# def feet_2_meter(feet: NumberLike = 1):
# def meter_2_feet(meter: NumberLike = 1):
# def db_per_100feet_2_db_per_100meter(db_per_100feet: NumberLike = 1):
# def unwrap_rad(phi: NumberLike):
# def sqrt_known_sign(z_squared: NumberLike, z_approx: NumberLike):
# def find_correct_sign(z1: NumberLike, z2: NumberLike, z_approx: NumberLike):
# def find_closest(z1: NumberLike, z2: NumberLike, z_approx: NumberLike):
# def sqrt_phase_unwrap(z: NumberLike):
# def dirac_delta(x: NumberLike):
# def neuman(x: NumberLike):
# def null(A: npy.ndarray, eps: float = 1e-15):
# def inf_to_num(x: NumberLike):
# def cross_ratio(a: NumberLike, b: NumberLike, c: NumberLike, d:NumberLike):
# def complexify(f: Callable, name: str = None):
#     def f_c(z, *args, **kw):
# def complex2Scalar(z: NumberLike):
# def scalar2Complex(s: NumberLike):
# def flatten_c_mat(s: NumberLike, order: str = 'F'):
# def rand_c(*args) -> npy.ndarray:
# def psd2TimeDomain(f: npy.ndarray, y: npy.ndarray, windowType: str = 'hamming'):
# def rational_interp(x: npy.ndarray, y: npy.ndarray, d: int = 4, epsilon: float = 1e-9, axis: int = 0, assume_sorted: bool = False) -> Callable:
#     def fx(xi):
# def ifft(x: npy.ndarray) -> npy.ndarray:
# def irfft(x: npy.ndarray, n:int = None) -> npy.ndarray:
# def is_square(mat: npy.ndarray) -> bool:
# def is_unitary(mat: npy.ndarray, tol: float = ALMOST_ZERO) -> bool:
# def is_symmetric(mat: npy.ndarray, tol: int = ALMOST_ZERO) -> bool:
# def get_Hermitian_transpose(mat: npy.ndarray) -> npy.ndarray:
# def is_Hermitian(mat: npy.ndarray, tol: float = ALMOST_ZERO) -> bool:
# def is_positive_definite(mat: npy.ndarray, tol: float = ALMOST_ZERO) -> bool:
# def is_positive_semidefinite(mat: npy.ndarray, tol: float = ALMOST_ZERO) -> bool:
#     T = 1./df


# Path: skrf/tests/test_mathFunctions.py
from skrf.mathFunctions import LOG_OF_NEG
from numpy import e, log, pi, isnan, inf
from numpy.testing import assert_equal, run_module_suite, assert_almost_equal
import skrf as rf
import unittest
import numpy as np

        """
        Test complex to quadrature conversion with:
            2, pi  = abs(2j), angle(2j) * abs(2j) 
        """
        assert_almost_equal(rf.complex_2_quadrature(0+2j), (2, pi))


    def test_complex_components(self):
        """
        Test complex components:
        """
        assert_almost_equal(rf.complex_components(0+2j), (0, 2, 90, 2, pi))


    def test_complex_2_reim(self):
        """
        Test complex to (real, imag) conversion:
        """
        assert_almost_equal(rf.complex_2_reim(1+2j), (1,2))


    def test_magnitude_2_db(self):
        """
        Test magnitude to db conversion
        """
        assert_almost_equal(rf.magnitude_2_db(10, True), 20)
        assert_almost_equal(rf.magnitude_2_db(10, False), 20)

        assert_almost_equal(rf.magnitude_2_db(0), -inf)
        assert_almost_equal(rf.magnitude_2_db(-1, True), LOG_OF_NEG)

        assert_almost_equal(rf.magnitude_2_db([10, -1], True), [20, LOG_OF_NEG])