Skip to content

Commit a5e2eae

Browse files
committed
Remove usage of input in test_containers.py
1 parent da7dda1 commit a5e2eae

File tree

1 file changed

+64
-42
lines changed

1 file changed

+64
-42
lines changed

tests/test_containers.py

Lines changed: 64 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,105 +5,127 @@
55

66

77
@pytest.mark.parametrize(
8-
"inputs, expected",
8+
"grid, number_of_signals, id_number, iq, stretching_factor, expected",
99
[
1010
(
11-
[np.arange(10), 3, 0, [6.55, 0.357, 8.49, 9.33, 6.78, 7.57, 7.43, 3.92, 6.55, 1.71], 0.25],
11+
np.arange(10),
12+
3,
13+
0,
14+
[6.55, 0.357, 8.49, 9.33, 6.78, 7.57, 7.43, 3.92, 6.55, 1.71],
15+
0.25,
1216
[
1317
[6.55, 6.78, 6.55, 0, 0, 0, 0, 0, 0, 0],
1418
[0, 14.07893122, 35.36478086, 0, 0, 0, 0, 0, 0, 0],
1519
[0, -19.92049156, 11.6931482, 0, 0, 0, 0, 0, 0, 0],
1620
],
1721
),
1822
(
19-
[np.arange(5), 10, 0, [-11.47, -10.688, -8.095, -29.44, 14.38], 1.25],
23+
np.arange(5),
24+
10,
25+
0,
26+
[-11.47, -10.688, -8.095, -29.44, 14.38],
27+
1.25,
2028
[
2129
[-11.47, -10.8444, -9.1322, -16.633, -20.6760],
2230
[0, -0.50048, -3.31904, 40.9824, -112.1792],
2331
[0, 0.800768, 5.310464, -65.57184, 179.48672],
2432
],
2533
),
2634
(
27-
[np.arange(5), 2, 0, [-11.47, -10.688, -8.095, -29.44, 14.38], 0.88],
35+
np.arange(5),
36+
2,
37+
0,
38+
[-11.47, -10.688, -8.095, -29.44, 14.38],
39+
0.88,
2840
[
2941
[-11.47, -10.3344, -13.9164, -11.5136, 0],
3042
[0, -3.3484, 55.1265, -169.7572, 0],
3143
[0, 7.609997, -125.2876, 385.81189, 0],
3244
],
3345
),
3446
(
35-
[np.arange(10), 1, 2, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 0.88],
47+
np.arange(10),
48+
1,
49+
2,
50+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
51+
0.88,
3652
[
3753
[1, 2.1364, 3.2727, 4.4091, 5.5455, 6.6818, 7.8182, 8.9545, 0, 0],
3854
[0, -1.29, -2.58, -3.87, -5.165, -6.45, -7.74, -9.039, 0, 0],
3955
[0, 2.93, 5.869, 8.084, 11.739, 14.674, 17.608, 20.5437, 0, 0],
4056
],
4157
),
4258
(
59+
np.arange(14),
60+
100,
61+
3,
4362
[
44-
np.arange(14),
45-
100,
46-
3,
47-
[
48-
-2.9384,
49-
-1.4623,
50-
-2.0913,
51-
4.6304,
52-
-1.2127,
53-
1.4737,
54-
-0.3791,
55-
1.7506,
56-
-1.5068,
57-
-2.7625,
58-
0.9617,
59-
-0.3494,
60-
-0.3862,
61-
2.7960,
62-
],
63-
0.55,
63+
-2.9384,
64+
-1.4623,
65+
-2.0913,
66+
4.6304,
67+
-1.2127,
68+
1.4737,
69+
-0.3791,
70+
1.7506,
71+
-1.5068,
72+
-2.7625,
73+
0.9617,
74+
-0.3494,
75+
-0.3862,
76+
2.7960,
6477
],
78+
0.55,
6579
[
6680
[-2.9384, -1.9769, 0.9121, 0.6314, 0.8622, -2.4239, -0.2302, 1.9281, 0, 0, 0, 0, 0, 0],
6781
[0, 2.07933, 38.632, 18.3748, 43.07305, -61.557, 26.005, -73.637, 0, 0, 0, 0, 0, 0],
6882
[0, -7.56, -140.480, -66.81, -156.6293, 223.84, -94.564, 267.7734, 0, 0, 0, 0, 0, 0],
6983
],
7084
),
7185
(
72-
[np.arange(11), 20, 4, [0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5], 0.987],
86+
np.arange(11),
87+
20,
88+
4,
89+
[0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5],
90+
0.987,
7391
[
7492
[0, 0.2533, 0.5066, 0.7599, 1.0132, 1.2665, 1.5198, 1.7730, 2.0263, 2.2796, 0],
7593
[0, -0.2566, -0.5132, -0.7699, -1.0265, -1.2831, -1.5398, -1.7964, -2.0530, -2.3097, 0],
7694
[0, 0.5200, 1.0400, 1.56005, 2.08007, 2.6000, 3.1201, 3.6401, 4.1601, 4.6801, 0],
7795
],
7896
),
7997
(
80-
[np.arange(9), 15, 3, [-1, -2, -3, -4, -5, -6, -7, -8, -9], -0.4],
98+
np.arange(9),
99+
15,
100+
3,
101+
[-1, -2, -3, -4, -5, -6, -7, -8, -9],
102+
-0.4,
81103
[[-1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],
82104
),
83105
],
84106
)
85-
def test_apply_stretch(inputs, expected):
86-
component = ComponentSignal(inputs[0], inputs[1], inputs[2])
87-
component.iq = inputs[3]
88-
component.stretching_factors[0] = inputs[4]
107+
def test_apply_stretch(grid, number_of_signals, id_number, iq, stretching_factor, expected):
108+
component = ComponentSignal(grid, number_of_signals, id_number)
109+
component.iq = iq
110+
component.stretching_factors[0] = stretching_factor
89111
actual = component.apply_stretch(0)
90112
np.testing.assert_allclose(actual, expected, rtol=1e-01)
91113

92114

93115
@pytest.mark.parametrize(
94-
"inputs, expected",
116+
"grid, number_of_signals, id_number, iq, weight, expected",
95117
[
96-
([np.arange(5), 2, 0, [0, 1, 2, 3, 4], 0.5], [0, 0.5, 1, 1.5, 2]),
97-
([np.arange(5), 20, 2, [0, -1, -2, -3, -4], 0.25], [0, -0.25, -0.5, -0.75, -1]),
98-
([np.arange(40), 200, 4, np.arange(0, 10, 0.25), 0.3], np.arange(0, 10, 0.25) * 0.3),
99-
([np.arange(1), 10, 2, [10.5, 11.5, -10.5], 0], [0, 0, 0]),
100-
([[-12, -10, -15], 5, 2, [-0.5, -1, -1.2], 0.9], [-0.45, -0.9, -1.08]),
101-
([[-12, -10, -15], 5, 2, [0, 0, 0], 0.9], [0, 0, 0]),
118+
(np.arange(5), 2, 0, [0, 1, 2, 3, 4], 0.5, [0, 0.5, 1, 1.5, 2]),
119+
(np.arange(5), 20, 2, [0, -1, -2, -3, -4], 0.25, [0, -0.25, -0.5, -0.75, -1]),
120+
(np.arange(40), 200, 4, np.arange(0, 10, 0.25), 0.3, np.arange(0, 10, 0.25) * 0.3),
121+
(np.arange(1), 10, 2, [10.5, 11.5, -10.5], 0, [0, 0, 0]),
122+
([-12, -10, -15], 5, 2, [-0.5, -1, -1.2], 0.9, [-0.45, -0.9, -1.08]),
123+
([-12, -10, -15], 5, 2, [0, 0, 0], 0.9, [0, 0, 0]),
102124
],
103125
)
104-
def test_apply_weight(inputs, expected):
105-
component = ComponentSignal(inputs[0], inputs[1], inputs[2])
106-
component.iq = np.array(inputs[3])
107-
component.weights[0] = inputs[4]
126+
def test_apply_weight(grid, number_of_signals, id_number, iq, weight, expected):
127+
component = ComponentSignal(grid, number_of_signals, id_number)
128+
component.iq = np.array(iq)
129+
component.weights[0] = weight
108130
actual = component.apply_weight(0)
109131
np.testing.assert_allclose(actual, expected, rtol=1e-04)

0 commit comments

Comments
 (0)