diff --git a/reinforced_lib/logs/stdout_logger.py b/reinforced_lib/logs/stdout_logger.py index f475da8..6da4ab4 100644 --- a/reinforced_lib/logs/stdout_logger.py +++ b/reinforced_lib/logs/stdout_logger.py @@ -37,11 +37,7 @@ def finish(self) -> None: """ if len(self._values) > 0: - for name in self._names: - if name in self._values: - print(f'{name}: {self._values[name]}', end='\t') - - print() + print('\t'.join(f'{name}: {value}' for name, value in self._values.items())) def log_scalar(self, source: Source, value: Scalar) -> None: """ @@ -55,7 +51,8 @@ def log_scalar(self, source: Source, value: Scalar) -> None: Scalar to log. """ - self._print(source, value) + self._values[self.source_to_name(source)] = value + self._print() def log_array(self, source: Source, value: Array) -> None: """ @@ -100,27 +97,14 @@ def log_other(self, source: Source, value: Any) -> None: Value of any type to log. """ - self._print(source, json.dumps(value)) + self._values[self.source_to_name(source)] = json.dumps(value) + self._print() - def _print(self, source: Source, value: Any) -> None: + def _print(self) -> None: """ - Prints a new row to the standard output if there is any value update. - - Parameters - ---------- - source : Source - Source of the logged value. - value : any - Value of any type to log. + Prints a new row to the standard output if all values has already been filled. """ - if not (name := self.source_to_name(source)) in self._values: - self._values[name] = value - return - - for name in self._names: - if name in self._values: - print(f'{name}: {self._values[name]}', end='\t') - - self._values = {} - print() + if len(self._values) == len(self._names): + print('\t'.join(f'{name}: {self._values[name]}' for name in self._names)) + self._values = {} diff --git a/requirements/requirements-dev.txt b/requirements/requirements-dev.txt index 9048f69..6c53050 100644 --- a/requirements/requirements-dev.txt +++ b/requirements/requirements-dev.txt @@ -1,6 +1,6 @@ -joblib~=1.2.0 +joblib~=1.3.1 # ns3-ai==1.0.2 -pygame~=2.3.0 +pygame~=2.5.0 seaborn~=0.12.2 sphinx~=5.1.1 sphinx-rtd-theme~=1.0.0 \ No newline at end of file diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 5a50408..7dcd2b9 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,10 +1,10 @@ -chex~=0.1.5 -cloudpickle~=2.2.0 +chex~=0.1.81 +cloudpickle~=2.2.1 dm-haiku~=0.0.9 -gymnasium~=0.27.1 -jax~=0.4.6 -jaxlib~=0.4.6 +gymnasium~=0.28.1 +jax~=0.4.13 +jaxlib~=0.4.13 lz4~=4.3.2 -matplotlib~=3.7.1 -optax~=0.1.4 -tensorboardX~=2.6 \ No newline at end of file +matplotlib~=3.7.2 +optax~=0.1.5 +tensorboardX~=2.6.1 \ No newline at end of file