test_convert_dataframe3()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 17
Ratio 100 %

Importance

Changes 0
Metric Value
eloc 11
dl 17
loc 17
rs 9.85
c 0
b 0
f 0
cc 1
nop 0
1
# Author: Simon Blanke
2
# Email: [email protected]
3
# License: MIT License
4
5
import pytest
6
import numpy as np
7
import pandas as pd
8
from pandas.testing import assert_frame_equal
9
10
from optimization_metadata.memory_conv import convert_dataframe
11
12
13 View Code Duplication
def test_convert_dataframe1():
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
14
    array = np.reshape(np.arange(20), (10, 2))
15
    df1 = pd.DataFrame(array, columns=["x1", "x2"])
16
17
    search_space1 = {
18
        "x1": list(np.arange(20)),
19
        "x2": list(np.arange(20)),
20
    }
21
    search_space2 = {
22
        "x1": list(np.arange(20)),
23
        "x2": list(np.arange(20)),
24
    }
25
    df2 = convert_dataframe(df1, search_space1, search_space2)
26
27
    assert_frame_equal(df1, df2, check_dtype=False)
28
29
30 View Code Duplication
def test_convert_dataframe2():
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
31
    array = np.reshape(np.arange(20), (10, 2))
32
    df1 = pd.DataFrame(array, columns=["x1", "x2"])
33
34
    search_space1 = {
35
        "x1": list(np.arange(20)),
36
        "x2": list(np.arange(20)),
37
    }
38
    search_space2 = {
39
        "x1": list(np.arange(5)),
40
        "x2": list(np.arange(20)),
41
    }
42
    df2 = convert_dataframe(df1, search_space1, search_space2)
43
44
    with pytest.raises(Exception):
45
        assert_frame_equal(df1, df2, check_dtype=False)
46
47
48 View Code Duplication
def test_convert_dataframe3():
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
49
    array = np.reshape(np.arange(20), (10, 2))
50
    df1 = pd.DataFrame(array, columns=["x1", "x2"])
51
52
    search_space1 = {
53
        "x1": list(np.arange(20)),
54
        "x2": list(np.arange(20)),
55
    }
56
    search_space2 = {
57
        "x1": list(np.arange(20)),
58
        # "x2": list(np.arange(20)),
59
    }
60
    df2 = convert_dataframe(df1, search_space1, search_space2)
61
62
    df1.drop("x2", axis=1, inplace=True)
63
64
    assert_frame_equal(df1, df2, check_dtype=False)
65
66