# Path: hftools/testing/common.py
# class TestCase(unittest.TestCase):
#     def assertAllclose(self, a, b, rtol=1e-05, atol=1e-08, msg=None):
#         a = np.asanyarray(a)
#         b = np.asanyarray(b)
#         if msg is None:
#             msg = "a (%s) not close to b (%s)" % (a, b)
#         self.assertTrue(np.allclose(a, b, rtol, atol), msg)
# 
#     def assertIsNotInstance(self, obj, cls):
#         self.assertFalse(isinstance(obj, cls))
# 
#     def assertIsInstance(self, obj, cls, msg=None):
#         """Same as self.assertTrue(isinstance(obj, cls)), with a nicer
#         default message."""
#         if not isinstance(obj, cls):
#             arg = (unittest.case.safe_repr(obj), cls)
#             standardMsg = '%s is not an instance of %r' % arg
#             self.fail(self._formatMessage(msg, standardMsg))
# 
#     def assertHFToolsWarning(self, funk, *k, **kw):
#         warnings.resetwarnings()
#         warnings.simplefilter("error", HFToolsWarning)
#         self.assertRaises(HFToolsWarning, funk, *k, **kw)
#         warnings.simplefilter("ignore", HFToolsWarning)
# 
#     def assertHFToolsDeprecationWarning(self, funk, *k, **kw):
#         warnings.resetwarnings()
#         warnings.simplefilter("error", HFToolsDeprecationWarning)
#         self.assertRaises(HFToolsDeprecationWarning, funk, *k, **kw)
#         warnings.simplefilter("ignore", HFToolsDeprecationWarning)
# 
# def random_complex_matrix(N, maxsize, minsize=1, Nmatrix=2, Nmatrixj=None):
#     if Nmatrixj is None:  # pragma: no cover
#         Nmatrixj = Nmatrix
#     dims = (random_dims(N, maxsize, minsize) +
#             (DimMatrix_i("i", Nmatrix), DimMatrix_j("j", Nmatrixj)))
#     return (random_value_array_from_dims(dims) +
#             random_value_array_from_dims(dims) * 1j)
# 
# Path: hftools/utils.py
# def reset_hftools_warnings():
# def timestamp(highres=False):
# def warn(msg):
# def deprecate(msg):
#     def isnumber(x):
#     def isrealnumber(x):
#     def isnumber(x):
#     def isrealnumber(x):
# def is_numlike(a):
# def is_integer(a):
# def to_numeric(value, error=True):
# def stable_uniq(data):
# def uniq(data):
# def chop(x, rtol=1e-9, atol=1e-15):
# def make_dirs(*pathsegments):
# def split_num(string):
# def lex_order(lista):
# def glob(pat):
#     def beep(freq=None, duration=50):
#     def beep(freq=None, duration=50):
# def flatten(lista):


import os
import warnings
import numpy as np
import hftools.dataset.arrayobj as aobj
import hftools.networks.multiports as mp
from hftools.testing import TestCase, random_complex_matrix
from hftools.utils import HFToolsWarning
class Test_ABCDArray_1(Test_TwoPortArray):
    cls = mp.ABCDArray


class Test_SArray_1(Test_MultiPortArray):
    cls = mp.SArray


class Test_TArray_1(Test_TwoPortArray):
    cls = mp.TArray


class Test_TPArray_1(Test_TwoPortArray):
    cls = mp.TpArray


class Test_unit_matrices(TestCase):
    def test_unit_matrix(self):
        m = mp.unit_matrix()
        self.assertEqual(m.shape, (2, 2))
        self.assertIsInstance(m, mp.SArray)
        self.assertAllclose(m, [[1, 0], [0, 1]])

    def test_unit_smatrix(self):
        m = mp.unit_smatrix()
        self.assertEqual(m.shape, (2, 2))
        self.assertIsInstance(m, mp.SArray)
        self.assertAllclose(m, [[0, 1], [1, 0]])



# Path: hftools/testing/common.py
# class TestCase(unittest.TestCase):
#     def assertAllclose(self, a, b, rtol=1e-05, atol=1e-08, msg=None):
#         a = np.asanyarray(a)
#         b = np.asanyarray(b)
#         if msg is None:
#             msg = "a (%s) not close to b (%s)" % (a, b)
#         self.assertTrue(np.allclose(a, b, rtol, atol), msg)
# 
#     def assertIsNotInstance(self, obj, cls):
#         self.assertFalse(isinstance(obj, cls))
# 
#     def assertIsInstance(self, obj, cls, msg=None):
#         """Same as self.assertTrue(isinstance(obj, cls)), with a nicer
#         default message."""
#         if not isinstance(obj, cls):
#             arg = (unittest.case.safe_repr(obj), cls)
#             standardMsg = '%s is not an instance of %r' % arg
#             self.fail(self._formatMessage(msg, standardMsg))
# 
#     def assertHFToolsWarning(self, funk, *k, **kw):
#         warnings.resetwarnings()
#         warnings.simplefilter("error", HFToolsWarning)
#         self.assertRaises(HFToolsWarning, funk, *k, **kw)
#         warnings.simplefilter("ignore", HFToolsWarning)
# 
#     def assertHFToolsDeprecationWarning(self, funk, *k, **kw):
#         warnings.resetwarnings()
#         warnings.simplefilter("error", HFToolsDeprecationWarning)
#         self.assertRaises(HFToolsDeprecationWarning, funk, *k, **kw)
#         warnings.simplefilter("ignore", HFToolsDeprecationWarning)
# 
# def random_complex_matrix(N, maxsize, minsize=1, Nmatrix=2, Nmatrixj=None):
#     if Nmatrixj is None:  # pragma: no cover
#         Nmatrixj = Nmatrix
#     dims = (random_dims(N, maxsize, minsize) +
#             (DimMatrix_i("i", Nmatrix), DimMatrix_j("j", Nmatrixj)))
#     return (random_value_array_from_dims(dims) +
#             random_value_array_from_dims(dims) * 1j)
# 
# Path: hftools/utils.py
# def reset_hftools_warnings():
# def timestamp(highres=False):
# def warn(msg):
# def deprecate(msg):
#     def isnumber(x):
#     def isrealnumber(x):
#     def isnumber(x):
#     def isrealnumber(x):
# def is_numlike(a):
# def is_integer(a):
# def to_numeric(value, error=True):
# def stable_uniq(data):
# def uniq(data):
# def chop(x, rtol=1e-9, atol=1e-15):
# def make_dirs(*pathsegments):
# def split_num(string):
# def lex_order(lista):
# def glob(pat):
#     def beep(freq=None, duration=50):
#     def beep(freq=None, duration=50):
# def flatten(lista):


# Path: hftools/networks/tests/test_multiports.py
import os
import warnings
import numpy as np
import hftools.dataset.arrayobj as aobj
import hftools.networks.multiports as mp
from hftools.testing import TestCase, random_complex_matrix
from hftools.utils import HFToolsWarning

class Test_ABCDArray_1(Test_TwoPortArray):
    cls = mp.ABCDArray


class Test_SArray_1(Test_MultiPortArray):
    cls = mp.SArray


class Test_TArray_1(Test_TwoPortArray):
    cls = mp.TArray


class Test_TPArray_1(Test_TwoPortArray):
    cls = mp.TpArray


class Test_unit_matrices(TestCase):
    def test_unit_matrix(self):
        m = mp.unit_matrix()
        self.assertEqual(m.shape, (2, 2))
        self.assertIsInstance(m, mp.SArray)
        self.assertAllclose(m, [[1, 0], [0, 1]])

    def test_unit_smatrix(self):
        m = mp.unit_smatrix()
        self.assertEqual(m.shape, (2, 2))
        self.assertIsInstance(m, mp.SArray)
        self.assertAllclose(m, [[0, 1], [1, 0]])



class TestConversions(TestCase):