test_disaggregate_timeindex()   A
last analyzed

Complexity

Conditions 3

Size

Total Lines 24
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 24
rs 9.55
c 0
b 0
f 0
cc 3
nop 0
1
# -*- coding: utf-8 -*-
2
3
import pandas as pd
4
5
from oemof.solph import processing
6
7
8
def test_disaggregate_timeindex():
9
    ti_1 = pd.date_range("2020-01-01", periods=10, freq="h")
10
    ti_2 = pd.date_range("2030-01-01", periods=20, freq="h")
11
    ti_3 = pd.date_range("2040-01-01", periods=40, freq="h")
12
    ti = ti_1.union(ti_2).union(ti_3)
13
14
    periods = [ti_1, ti_2, ti_3]
15
    tsa_parameters = [
16
        {"timesteps_per_period": 5, "order": [1, 0]},
17
        {"timesteps_per_period": 5, "order": [1, 0, 0, 1]},
18
        {"timesteps_per_period": 10, "order": [1, 0, 0, 1]},
19
    ]
20
21
    for p, period_data in enumerate(tsa_parameters):
22
        if p == 0:
23
            result_index = processing._disaggregate_tsa_timeindex(
24
                periods[p], period_data
25
            )
26
        else:
27
            result_index = result_index.union(
0 ignored issues
show
introduced by
The variable result_index does not seem to be defined in case the for loop on line 21 is not entered. Are you sure this can never be the case?
Loading history...
28
                processing._disaggregate_tsa_timeindex(periods[p], period_data)
29
            )
30
31
    assert all(result_index == ti)
32