-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_mlib.py
32 lines (24 loc) · 896 Bytes
/
test_mlib.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from mlib import human_readable_payload, get_position_zone, scale_target
import numpy as np
import pandas as pd
def test_human_readable_payload():
result = human_readable_payload(1.5)
assert 1.5 == result["value_log"]
assert "4.48 euros" == result["value_money"]
def test_get_position_zone():
# intialise data of lists.
data = {
"preferred_positions": [["LF", "RF", "CAM"], ["CAM"], ["LWB", "RWB", "RB"]],
"name": ["test1", "test2", "test3"],
}
# Create DataFrame
df = pd.DataFrame(data)
result = get_position_zone(df)
assert ["ATTACKING", "MIDFIELD", "DEFENDING"] == result["position_zone"].tolist()
def test_scale_target():
# intialise data of lists.
data = {"Value": [1, 3, 4, 3, 4, 5]}
# Create DataFrame
df = pd.DataFrame(data)
result = scale_target([[1]], df)
assert 1.62 == float(np.round(result, 2))