simplified tests, added docstrings
@@ -864,32 +864,43 @@ class NetworkTestCase(unittest.TestCase):
def test_generate_subnetworks_nportsbelow10(self):
+ '''
+ Testing generation of one-port subnetworks for ports below 10
+ '''
ntwk = rf.Network(os.path.join(self.test_dir,'ntwk.s32p'))
npy.testing.assert_array_almost_equal(
ntwk.s[:,4,5],
- ntwk.__getattribute__(f's{4+1}_{5+1}').s[:,0,0]
+ ntwk.s5_6.s[:,0,0]
)
def test_generate_subnetworks_nportsabove10(self):
+ '''
+ Testing generation of one-port subnetworks for ports above 10
+ '''
ntwk = rf.Network(os.path.join(self.test_dir,'ntwk.s32p'))
npy.testing.assert_array_almost_equal(
ntwk.s[:,1,15],
- ntwk.__getattribute__(f's{1+1}_{15+1}').s[:,0,0]
+ ntwk.s2_16.s[:,0,0]
)
def test_generate_subnetwork_nounderscore(self):
+ '''
+ Testing no underscore alias of one-port subnetworks for ports below 10.
+ This is for backward compatibility with old code.
+ '''
ntwk = rf.Network(os.path.join(self.test_dir,'ntwk.s32p'))
- for m in range(ntwk.nports):
- for n in range(ntwk.nports):
- if m < 9 and n < 9:
+
npy.testing.assert_array_almost_equal(
- ntwk.s[:, m, n],
- ntwk.__getattribute__(f's{m+1}{n+1}').s[:, 0, 0]
+ ntwk.s[:, 8, 8],
+ ntwk.s99.s[:,0,0]
)
def test_generate_subnetworks_allports(self):
+ '''
+ Testing generation of all one-port subnetworks in case of edge problems.
+ '''
ntwk = rf.Network(os.path.join(self.test_dir,'ntwk.s32p'))
for m in range(ntwk.nports):
for n in range(ntwk.nports):
