Skip to content

Commit 90d0a49

Browse files
committed
ruff fix
1 parent 0aa51cb commit 90d0a49

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

agents/rl_das/trainer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,12 @@ def train(
131131
# Log per-epoch PPO diagnostics so training instability is visible
132132
# (e.g. actor_loss explosion, entropy collapse) without manual debugging.
133133
if epoch_diagnostics:
134-
entry["actor_loss"] = float(np.mean([d["actor_loss"] for d in epoch_diagnostics]))
135-
entry["critic_loss"] = float(np.mean([d["critic_loss"] for d in epoch_diagnostics]))
134+
entry["actor_loss"] = float(
135+
np.mean([d["actor_loss"] for d in epoch_diagnostics])
136+
)
137+
entry["critic_loss"] = float(
138+
np.mean([d["critic_loss"] for d in epoch_diagnostics])
139+
)
136140
entry["entropy"] = float(np.mean([d["entropy"] for d in epoch_diagnostics]))
137141

138142
if epoch % eval_interval == 0:

das/env/das_env.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import gymnasium as gym
1717
from gymnasium import spaces
1818

19-
from das.env.observation import (compute_observation, observation_dim, MAX_HISTORY_SAMPLE)
19+
from das.env.observation import compute_observation, observation_dim, MAX_HISTORY_SAMPLE
2020
from das.env.reward import compute_reward
2121
from das.optimizers.base import get_checkpoints
2222

@@ -234,7 +234,9 @@ def _update_episode_state(self, result: dict, prev_best_y: float):
234234
# derive scale from the magnitude of the initial best fitness.
235235
if self._initial_range[0] == float("inf"):
236236
safe_worst = (
237-
worst_y if np.isfinite(worst_y) else new_best_y + max(abs(new_best_y), 1.0)
237+
worst_y
238+
if np.isfinite(worst_y)
239+
else new_best_y + max(abs(new_best_y), 1.0)
238240
)
239241
self._initial_range = (new_best_y, max(safe_worst, new_best_y + 1e-5))
240242

das/training/rldas.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ def run_rl_das(args) -> None:
3030

3131
# Local variable — avoid mutating args so the caller's namespace stays predictable.
3232
k_epoch = (
33-
args.k_epoch if args.k_epoch is not None
33+
args.k_epoch
34+
if args.k_epoch is not None
3435
else max(1, int(0.3 * args.n_checkpoints))
3536
)
3637

@@ -82,8 +83,7 @@ def run_rl_das(args) -> None:
8283
# have incompatible scales so mean(best_y) is a meaningless aggregate.
8384
global_optima = load_global_optima()
8485
gaps = [
85-
r["best_y"] - global_optima.get(r["problem_id"], 0.0)
86-
for r in test_results
86+
r["best_y"] - global_optima.get(r["problem_id"], 0.0) for r in test_results
8787
]
8888
print(f"Test mean gap = {float(np.mean(gaps)):.6e}")
8989
print(f"Test median gap = {float(np.median(gaps)):.6e}")

0 commit comments

Comments
 (0)