spinx going book

This commit is contained in:
Steffen Illium
2023-12-12 17:51:37 +01:00
parent 7feba6d452
commit e7933985cb
44 changed files with 392 additions and 310 deletions

View File

@@ -1,3 +1,11 @@
from . import helpers as h
from . import helpers
from .results import Result, DoneResult, ActionResult, TickResult
"""
Utils
=====
Todo
"""

View File

@@ -21,11 +21,11 @@ class FactoryConfigParser(object):
def __init__(self, config_path, custom_modules_path: Union[PathLike] = None):
"""
This class parses the factory env config file.
This class parses the factory env config file.
:param config_path: Test
:param custom_modules_path: Test
:param config_path: Path to where the 'config.yml' is.
:param custom_modules_path: Additional search path for custom modules, levels, entities, etc..
"""
self.config_path = Path(config_path)
self.custom_modules_path = Path(custom_modules_path) if custom_modules_path is not None else custom_modules_path

View File

@@ -0,0 +1,7 @@
"""
logging
=======
Todo
"""

View File

@@ -11,6 +11,13 @@ class EnvRecorder(Wrapper):
def __init__(self, env, filepath: Union[str, PathLike] = None,
episodes: Union[List[int], None] = None):
"""
Todo
:param env:
:param filepath:
"""
super(EnvRecorder, self).__init__(env)
self.filepath = filepath
self.episodes = episodes

View File

@@ -31,6 +31,9 @@ class OBSBuilder(object):
def __init__(self, level_shape: np.size, state: Gamestate, pomdp_r: int):
"""
OBSBuilder
==========
TODO

View File

@@ -0,0 +1,7 @@
"""
PLotting
========
Todo
"""

View File

@@ -13,6 +13,14 @@ MODEL_MAP = None
def compare_seed_runs(run_path: Union[str, PathLike], use_tex: bool = False):
"""
Todo
:param filepath:
:param ext:
:return:
"""
run_path = Path(run_path)
df_list = list()
for run, monitor_file in enumerate(run_path.rglob('monitor*.pick')):
@@ -49,6 +57,14 @@ def compare_seed_runs(run_path: Union[str, PathLike], use_tex: bool = False):
def compare_model_runs(run_path: Path, run_identifier: Union[str, int], parameter: Union[str, List[str]],
use_tex: bool = False):
"""
Todo
:param filepath:
:param ext:
:return:
"""
run_path = Path(run_path)
df_list = list()
parameter = [parameter] if isinstance(parameter, str) else parameter
@@ -89,6 +105,14 @@ def compare_model_runs(run_path: Path, run_identifier: Union[str, int], paramete
def compare_all_parameter_runs(run_root_path: Path, parameter: Union[str, List[str]],
param_names: Union[List[str], None] = None, str_to_ignore='', use_tex: bool = False):
"""
Todo
:param filepath:
:param ext:
:return:
"""
run_root_path = Path(run_root_path)
df_list = list()
parameter = [parameter] if isinstance(parameter, str) else parameter

View File

@@ -11,6 +11,14 @@ from marl_factory_grid.utils.plotting.plotting_utils import prepare_plot
def plot_single_run(run_path: Union[str, PathLike], use_tex: bool = False, column_keys=None,
file_key: str ='monitor', file_ext: str ='pkl'):
"""
Todo
:param filepath:
:param ext:
:return:
"""
run_path = Path(run_path)
df_list = list()
if run_path.is_dir():

View File

@@ -1,7 +1,6 @@
import seaborn as sns
import matplotlib as mpl
from matplotlib import pyplot as plt
PALETTE = 10 * (
"#377eb8",
"#4daf4a",
@@ -20,6 +19,14 @@ PALETTE = 10 * (
def plot(filepath, ext='png'):
"""
Todo
:param filepath:
:param ext:
:return:
"""
plt.tight_layout()
figure = plt.gcf()
ax = plt.gca()
@@ -35,6 +42,13 @@ def plot(filepath, ext='png'):
def prepare_tex(df, hue, style, hue_order):
"""
Todo
:param filepath:
:param ext:
:return:
"""
sns.set(rc={'text.usetex': True}, style='whitegrid')
lineplot = sns.lineplot(data=df, x='Episode', y='Score', ci=95, palette=PALETTE,
hue_order=hue_order, hue=hue, style=style)
@@ -45,6 +59,13 @@ def prepare_tex(df, hue, style, hue_order):
def prepare_plt(df, hue, style, hue_order):
"""
Todo
:param filepath:
:param ext:
:return:
"""
print('Struggling to plot Figure using LaTeX - going back to normal.')
plt.close('all')
sns.set(rc={'text.usetex': False}, style='whitegrid')
@@ -57,6 +78,13 @@ def prepare_plt(df, hue, style, hue_order):
def prepare_center_double_column_legend(df, hue, style, hue_order):
"""
Todo
:param filepath:
:param ext:
:return:
"""
print('Struggling to plot Figure using LaTeX - going back to normal.')
plt.close('all')
sns.set(rc={'text.usetex': False}, style='whitegrid')
@@ -70,6 +98,13 @@ def prepare_center_double_column_legend(df, hue, style, hue_order):
def prepare_plot(filepath, results_df, ext='png', hue='Measurement', style=None, use_tex=False):
"""
Todo
:param filepath:
:param ext:
:return:
"""
df = results_df.copy()
df[hue] = df[hue].str.replace('_', '-')
hue_order = sorted(list(df[hue].unique()))

View File

@@ -6,7 +6,10 @@ import numpy as np
class MarlFrameStack(gym.ObservationWrapper):
"""todo @romue404"""
"""
todo @romue404
"""
def __init__(self, env):
super().__init__(env)