# 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)


import os
import numpy as np
import hftools.dataset.arrayobj as aobj
import hftools.networks.spar_functions as spfun
from hftools.testing import TestCase
        self.assertTrue(np.allclose(r, self.c))

    def test_cascade_5(self):
        r = spfun.cascadeS(self.b, self.c)
        self.assertTrue(np.allclose(r, make_array([[[0.4, 0j], [0, 0.1]]])))

    def test_cascade_6(self):
        r = spfun.cascadeS(self.c, self.b)
        self.assertTrue(np.allclose(r, make_array([[[0.1, 0j], [0, 0.4]]])))


class Test_deembedleft(TestCase):
    def setUp(self):
        self.a = make_array([[[0, 1], [1, 0j]]])
        self.b = make_array([[[0, 2], [2, 0j]]])
        self.c = make_array([[[0.1, 0j], [0, 0.1]]])

    def test_cascade_1(self):
        r = spfun.deembedleft(self.a, self.a)
        self.assertTrue(np.allclose(r, self.a))

    def test_cascade_2(self):
        r = spfun.deembedleft(self.b, self.b)
        self.assertTrue(np.allclose(r, self.a))

    def test_cascade_3(self):
        r = spfun.deembedleft(self.b, self.c)
        self.assertTrue(np.allclose(r, make_array([[[0.025, 0j], [0, 0.1]]])))



# 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)


# Path: hftools/networks/tests/test_spar_functions.py
import os
import numpy as np
import hftools.dataset.arrayobj as aobj
import hftools.networks.spar_functions as spfun
from hftools.testing import TestCase

        self.assertTrue(np.allclose(r, self.c))

    def test_cascade_5(self):
        r = spfun.cascadeS(self.b, self.c)
        self.assertTrue(np.allclose(r, make_array([[[0.4, 0j], [0, 0.1]]])))

    def test_cascade_6(self):
        r = spfun.cascadeS(self.c, self.b)
        self.assertTrue(np.allclose(r, make_array([[[0.1, 0j], [0, 0.4]]])))


class Test_deembedleft(TestCase):
    def setUp(self):
        self.a = make_array([[[0, 1], [1, 0j]]])
        self.b = make_array([[[0, 2], [2, 0j]]])
        self.c = make_array([[[0.1, 0j], [0, 0.1]]])

    def test_cascade_1(self):
        r = spfun.deembedleft(self.a, self.a)
        self.assertTrue(np.allclose(r, self.a))

    def test_cascade_2(self):
        r = spfun.deembedleft(self.b, self.b)
        self.assertTrue(np.allclose(r, self.a))

    def test_cascade_3(self):
        r = spfun.deembedleft(self.b, self.c)
        self.assertTrue(np.allclose(r, make_array([[[0.025, 0j], [0, 0.1]]])))



class Test_deembedright(TestCase):