A python package that contains utility function on plots, tables and file management.
To install this python package run this command in your command line:
$ python setup.py install
A module for creating customized plots from a dataset
get_line_plot
: returns a line plot of a datasetget_hist_plot
: returns a bar plot of a datasetset_size
: set a predefined size ('small', 'medium', 'big') to a numerical valueget_size
: get a predefined size numerical valueset_dimension
: set amatplotlib.plotly
parameter to a certain predefined size
Create a line plot of a given dataset
import utils_unibs.plots as up
from utils_unibs.constants import C
dataset = [
[1, 2, 3, 4],
[1, 2, 4, 8],
[0, 0.301, 0.477, 0.602]
]
colors = [
"blue",
"red",
"green"
]
styles = [
"--",
"-",
"-"
]
markers = [
None,
"^",
"*"
]
labels = [
"linear",
"exp",
"log"
]
up.set_dimension(dimension="axes label", value="small")
up.set_dimension(dimension="legend title", value="big")
up.set_size("small", 13)
fig, ax = up.get_line_plot(
dataset=dataset,
xticks=range(4),
xticks_labels=["$T_0$", "$T_1$", "$T_2$", "$T_3$"],
yticks=range(0,9,2),
yticks_labels = ["zero", "two", "four", "six", "eight"],
labels=labels,
xlabel="Time",
ylabel="Value",
legend_title="Functions",
title="Math functions",
save_fig=None,
colors=colors,
styles=styles,
markers=markers,
)
A module for creating tables from a dataset
print_latex_table
: creates a latex table of a datasetprint_text_table
: creates a text table of a datasettranspose_latex_table
: transpose a latex table
Create a latex table of a given dataset and highlight the maximum value every two values in the same row
import utils_unibs.tables as ut
from utils_unibs.constants import C
dataset = [
[5, 4, 2, 3],
[9, 6, 9, 6],
[1, 0.3, 0.4, 0.6]
]
labels = [
"Attempt 1",
"Attempt 2",
"Attempt 3",
]
print(
ut.print_latex_table(
dataset=dataset,
labels=labels,
best=C.MAX,
axis=C.ROW,
count_vals=2,
precision=0,
hline=2
)
)
Attempt 1 & \bf{5} & 4 & 2 & \bf{3} \\
Attempt 2 & \bf{9} & 6 & \bf{9} & 6 \\ \hline
Attempt 3 & \bf{1} & 0 & 0 & \bf{1} \\
A module for loading and saving files. Supports txt, pddl, json and pickle files
load_from_folder
: load files from a given foldersave_file
: Saves a given object in a file
Load files from the folder dir
|-- file1
|-- file2.json
|-- file3.txt
import utils_unibs.files as uf
[f1, fnf, f2, f3] = uf.load_from_folder("dir", ["file1", "file_not_in_folder", "file2.json", "file3.txt"])
file1 loaded from dir
Could not load file_not_in_folder from dir
file2.json loaded from dir
file3.txt loaded from dir