Code Duplication    Length = 23-26 lines in 2 locations

tests/test_non_equidistant_time_index.py 2 locations

@@ 106-131 (lines=26) @@
103
            assert self.es.timeincrement[ts] == ti
104
        assert charge.isnull().any()
105
106
    def test_timesteps_timeincrements_with_storage_discharging(self):
107
        storage_content = [
108
            v["sequences"]["storage_content"]
109
            for k, v in self.comp.items()
110
            if k[0].label == "storage"
111
        ][0]
112
        # Storage content at the last time point is equal to the content of
113
        # the first time point because the storage is balanced.
114
        assert storage_content.iloc[0] == storage_content.iloc[-1]
115
116
        discharge = [
117
            v["sequences"]["flow"]
118
            for k, v in self.flows.items()
119
            if k[0].label == "storage"
120
        ][0]
121
122
        # Calculate the next storage content and verify it with the storage
123
        # content of the results (discharging).
124
        # Discharging - timestep (ts) with its timeincrement (ti)
125
        time = [(7, 1), (40, 0.5)]
126
        for ts, ti in time:
127
            assert (
128
                storage_content.iloc[ts]
129
                - (discharge.iloc[ts] + (discharge.iloc[ts] * 1 / 9)) * ti
130
            ) == pytest.approx(storage_content.iloc[ts + 1])
131
            assert self.es.timeincrement[ts] == ti
132
133
    def test_timeincrements(self):
134
        assert self.es.timeincrement.sum() == 48
@@ 82-104 (lines=23) @@
79
        cls.es = es
80
        cls.model = model
81
82
    def test_timesteps_timeincrements_with_storage_charging(self):
83
        storage_content = [
84
            v["sequences"]["storage_content"]
85
            for k, v in self.comp.items()
86
            if k[0].label == "storage"
87
        ][0]
88
        assert storage_content.iloc[0] == storage_content.iloc[-1]
89
90
        charge = [
91
            v["sequences"]["flow"]
92
            for k, v in self.flows.items()
93
            if k[1].label == "storage"
94
        ][0]
95
        # Calculate the next storage content and verify it with the storage
96
        # content of the results (charging).
97
        # Charging - timestep (ts) with its timeincrement (ti)
98
        time = [(23, 1), (24, 0.5)]
99
        for ts, ti in time:
100
            assert storage_content.iloc[ts] + charge.iloc[
101
                ts
102
            ] * ti == pytest.approx(storage_content.iloc[ts + 1])
103
            assert self.es.timeincrement[ts] == ti
104
        assert charge.isnull().any()
105
106
    def test_timesteps_timeincrements_with_storage_discharging(self):
107
        storage_content = [