Skip to content

fix: fix non-required inputs to be truly not required #278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions examples/aco_tsp/aco_tsp/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ def step(self):
self._traveled_distance = 0


# Don't create the TSPGraph.from_random as argument default: https://docs.astral.sh/ruff/rules/function-call-in-default-argument/
TSP_GRAPH = TSPGraph.from_random(20)


class AcoTspModel(mesa.Model):
"""The model class holds the model-level attributes, manages the agents, and generally handles
the global level of our model.
Expand All @@ -161,16 +165,12 @@ class AcoTspModel(mesa.Model):

def __init__(
self,
tsp_graph: TSPGraph | None,
num_agents: int = 20,
max_steps: int = int(1e6),
ant_alpha: float = 1.0,
ant_beta: float = 5.0,
tsp_graph: TSPGraph = TSP_GRAPH,
):
# Don't create the TSPGraph.from_random as argument default: https://docs.astral.sh/ruff/rules/function-call-in-default-argument/
if tsp_graph is None:
tsp_graph = TSPGraph.from_random(20)

super().__init__()
self.num_agents = num_agents
self.tsp_graph = tsp_graph
Expand Down
10 changes: 4 additions & 6 deletions rl/wolf_sheep/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
from ray.rllib.env import MultiAgentEnv
from utility import create_intial_agents, grid_to_observation

# Don't create the ABMSimulator as argument default: https://docs.astral.sh/ruff/rules/function-call-in-default-argument/
ABM_SIMULATOR = ABMSimulator()


class WolfSheepRL(WolfSheep, MultiAgentEnv):
def __init__(
self,
simulator: ABMSimulator | None,
width=20,
height=20,
initial_sheep=100,
Expand All @@ -25,12 +27,8 @@ def __init__(
sheep_gain_from_food=4,
seed=42,
vision=4,
simulator: ABMSimulator = ABM_SIMULATOR,
):
"""Create a new WolfRL-Sheep model with the given parameters."""
# Don't create the ABMSimulator as argument default: https://docs.astral.sh/ruff/rules/function-call-in-default-argument/
if simulator is None:
simulator = ABMSimulator()

super().__init__(
width,
height,
Expand Down
Loading