GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Push — main ( 38f5af...23f36e )
by Andreas
06:49
created

klib.scripts.performance.time_cat_plot()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
"""Measuring the performance of key functionality.
2
3
:author: Andreas Kanz
4
"""
5
import functools
6
from pathlib import Path
7
from time import perf_counter
8
9
import matplotlib.pyplot as plt
10
import pandas as pd
11
12
import klib
13
14
# Paths
15
base_path = Path(__file__).resolve().parents[3]
16
print(base_path)
17
data_path = base_path / "examples"
18
19
# Data Import
20
filepath = data_path / "NFL_DATASET.csv"
21
data = pd.read_csv(filepath)
22
23
24
def timer(func):
25
    @functools.wraps(func)
26
    def wrapper(*args, **kwargs):
27
        time_start = perf_counter()
28
        func(*args, **kwargs)
29
        return perf_counter() - time_start
30
31
    return wrapper
32
33
34
@timer
35
def time_data_cleaning():
36
    klib.data_cleaning(data, show=None)
37
38
39
@timer
40
def time_missingval_plot():
41
    klib.missingval_plot(data)
42
43
44
@timer
45
def time_dist_plot():
46
    klib.dist_plot(data.iloc[:, :5])
47
48
49
@timer
50
def time_cat_plot():
51
    klib.cat_plot(data)
52
53
54
def main():
55
    df_times = pd.DataFrame()
56
    df_times["data_cleaning"] = pd.Series([time_data_cleaning() for _ in range(12)])
57
    df_times["missingval_plot"] = pd.Series([time_missingval_plot() for _ in range(7)])
58
    df_times["dist_plot"] = pd.Series([time_dist_plot() for _ in range(7)])
59
    df_times["cat_plot"] = pd.Series([time_cat_plot() for _ in range(7)])
60
    df_times = df_times.fillna(df_times.mean())
61
    fig, ax = plt.subplots(nrows=1, ncols=4, figsize=(14, 7))
62
    reference_values = [5, 10, 10, 10]
63
64
    for i, (col, ref) in enumerate(
65
        zip(df_times.columns, reference_values, strict=True),
66
    ):
67
        ax[i].boxplot(df_times[col])
68
        ax[i].set_title(" ".join(col.split("_")).title())
69
        ax[i].axhline(ref)
70
    fig.suptitle("Performance", fontsize=16)
71
    fig.savefig("boxplots.png")
72
73
74
if __name__ == "__main__":
75
    main()
76