Skip to content

Commit 17c5bb6

Browse files
committed
Update test_tf_base.py
1 parent a587a52 commit 17c5bb6

File tree

1 file changed

+12
-36
lines changed

1 file changed

+12
-36
lines changed

tests/core/transfer_function/test_tf_base.py

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ def test_shape_zeros_dtype(self):
4141
self.assertEqual((tf.values == 0).all(), v_dict["empty"])
4242

4343
def test_frequency(self):
44-
self.assertEqual(
45-
(self.tf.frequency == 1.0 / np.arange(1, 3, 1)).all(), True
46-
)
44+
self.assertEqual((self.tf.frequency == 1.0 / np.arange(1, 3, 1)).all(), True)
4745

4846
def test_period(self):
4947
self.assertEqual((self.tf.period == np.arange(1, 3, 1)).all(), True)
@@ -55,9 +53,7 @@ def test_equal(self):
5553
class TestTFBaseTFErrorInput(unittest.TestCase):
5654
@classmethod
5755
def setUpClass(self):
58-
self.tf = TFBase(
59-
tf_error=np.array([[[0, 1], [1, 0]], [[1, 0], [0, 1]]])
60-
)
56+
self.tf = TFBase(tf_error=np.array([[[0, 1], [1, 0]], [[1, 0], [0, 1]]]))
6157
self.expected_shape = (2, 2, 2)
6258
self.expected = {
6359
"transfer_function": {"dtype": complex, "empty": True},
@@ -78,9 +74,7 @@ def test_shape_zeros_dtype(self):
7874
self.assertEqual((tf.values == 0).all(), v_dict["empty"])
7975

8076
def test_frequency(self):
81-
self.assertEqual(
82-
(self.tf.frequency == 1.0 / np.arange(1, 3, 1)).all(), True
83-
)
77+
self.assertEqual((self.tf.frequency == 1.0 / np.arange(1, 3, 1)).all(), True)
8478

8579
def test_period(self):
8680
self.assertEqual((self.tf.period == np.arange(1, 3, 1)).all(), True)
@@ -89,9 +83,7 @@ def test_period(self):
8983
class TestTFBaseTFModelErrorInput(unittest.TestCase):
9084
@classmethod
9185
def setUpClass(self):
92-
self.tf = TFBase(
93-
tf_model_error=np.array([[[0, 1], [1, 0]], [[1, 0], [0, 1]]])
94-
)
86+
self.tf = TFBase(tf_model_error=np.array([[[0, 1], [1, 0]], [[1, 0], [0, 1]]]))
9587
self.expected_shape = (2, 1, 1)
9688
self.expected = {
9789
"transfer_function": {"dtype": complex, "empty": True},
@@ -112,9 +104,7 @@ def test_shape_zeros_dtype(self):
112104
self.assertEqual((tf.values == 0).all(), v_dict["empty"])
113105

114106
def test_frequency(self):
115-
self.assertEqual(
116-
(self.tf.frequency == 1.0 / np.arange(1, 3, 1)).all(), True
117-
)
107+
self.assertEqual((self.tf.frequency == 1.0 / np.arange(1, 3, 1)).all(), True)
118108

119109
def test_period(self):
120110
self.assertEqual((self.tf.period == np.arange(1, 3, 1)).all(), True)
@@ -320,9 +310,7 @@ def setUpClass(self):
320310
self.new_periods = np.logspace(-3, 3, 12)
321311

322312
def interpolate(self, interp_type, bounds_error=False):
323-
interp_tf = spi.interp1d(
324-
self.period, self.tf, axis=0, kind=interp_type
325-
)
313+
interp_tf = spi.interp1d(self.period, self.tf, axis=0, kind=interp_type)
326314
interp_tf_error = spi.interp1d(
327315
self.period, self.tf_error, axis=0, kind=interp_type
328316
)
@@ -437,9 +425,7 @@ def setUpClass(self):
437425
frequency=1.0 / self.period,
438426
)
439427

440-
self.tf_interpolated_same_period = self.tf_base.interpolate(
441-
self.period
442-
)
428+
self.tf_interpolated_same_period = self.tf_base.interpolate(self.period)
443429

444430
self.new_period = np.logspace(-4, 4, 24)
445431
self.tf_interpolated_different_period = self.tf_base.interpolate(
@@ -471,9 +457,7 @@ def test_backfill_nans(self):
471457
)
472458
self.assertEqual(
473459
True,
474-
np.all(
475-
np.isclose(np.nan_to_num(self.tf), np.nan_to_num(new_tf_nans))
476-
),
460+
np.all(np.isclose(np.nan_to_num(self.tf), np.nan_to_num(new_tf_nans))),
477461
)
478462

479463
def test_same_tf(self):
@@ -494,9 +478,7 @@ def test_same_tf_error(self):
494478
True,
495479
np.all(
496480
np.isclose(
497-
np.nan_to_num(
498-
self.tf_base._dataset.transfer_function_error
499-
),
481+
np.nan_to_num(self.tf_base._dataset.transfer_function_error),
500482
np.nan_to_num(
501483
self.tf_interpolated_same_period._dataset.transfer_function_error
502484
),
@@ -509,9 +491,7 @@ def test_same_tf_model_error(self):
509491
True,
510492
np.all(
511493
np.isclose(
512-
np.nan_to_num(
513-
self.tf_base._dataset.transfer_function_model_error
514-
),
494+
np.nan_to_num(self.tf_base._dataset.transfer_function_model_error),
515495
np.nan_to_num(
516496
self.tf_interpolated_same_period._dataset.transfer_function_model_error
517497
),
@@ -532,15 +512,11 @@ def test_different_period_index(self):
532512
with self.subTest(
533513
f"period_min: in = {true_entry['input']} out = {true_entry['output']}"
534514
):
535-
self.assertTrue(
536-
true_entry["period_min"] <= new_entry["period_min"]
537-
)
515+
self.assertTrue(true_entry["period_min"] <= new_entry["period_min"])
538516
with self.subTest(
539517
f"period_max: in = {true_entry['input']} out = {true_entry['output']}"
540518
):
541-
self.assertTrue(
542-
true_entry["period_max"] >= new_entry["period_max"]
543-
)
519+
self.assertTrue(true_entry["period_max"] >= new_entry["period_max"])
544520

545521

546522
# =============================================================================

0 commit comments

Comments
 (0)