Properly implemented visualization._get_num_rows() and added unit tests

This commit is contained in:
2022-11-11 15:33:02 +01:00
parent b87129df2a
commit 6105eef4c1
2 changed files with 28 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ import matplotlib.pyplot as plt
import pandas as pd
import typing
from itertools import chain
import math
def _get_num_rows(num_graphs: int, num_cols: int) -> int:
@@ -13,7 +14,7 @@ def _get_num_rows(num_graphs: int, num_cols: int) -> int:
:param num_cols: Number of columns
:return: Number of rows
"""
return num_graphs // num_cols + 1
return math.ceil(num_graphs / num_cols)
# TODO: Calculate fig size in relation to the number of rows and columns
@@ -23,8 +24,8 @@ def _get_num_rows(num_graphs: int, num_cols: int) -> int:
def show_BER_curves(data: typing.List[pd.DataFrame], num_cols: int = 3) -> plt.figure:
"""This function creates a matplotlib figure containing a number of BER curves.
:param data: List of pandas DataFrames containing the data to be plotted. Each element in the list is plotted in
a new graph. Each dataframe is assumed to contain a column named "SNR" which is used as the x-axis
:param data: List of pandas DataFrames containing the data to be plotted. Each dataframe in the list is plotted
in a new graph. Each dataframe is assumed to contain a column named "SNR" which is used as the x-axis
:param num_cols: Number of columns in which the graphs should be arranged in the resulting figure
:return: Matplotlib figure
"""