Skip to content

Commit

Permalink
Deprecate SingleGrid.position_agent (projectmesa#1512)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tortar authored Nov 6, 2022
1 parent bfca50c commit 45171f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/schelling/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __init__(self, width=20, height=20, density=0.8, minority_pc=0.2, homophily=
agent_type = 0

agent = SchellingAgent((x, y), self, agent_type)
self.grid.position_agent(agent, x, y)
self.grid.place_agent(agent, (x, y))
self.schedule.add(agent)

self.running = True
Expand Down
10 changes: 10 additions & 0 deletions mesa/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,16 @@ def position_agent(
If x or y are positive, they are used.
Use 'swap_pos()' to swap agents positions.
"""
warn(
(
"`position_agent` is being deprecated; use instead "
"`place_agent` to place an agent at a specified "
"location or `move_to_empty` to place an agent "
"at a random empty cell."
),
DeprecationWarning,
)

if not (isinstance(x, int) or x == "random"):
raise Exception(
"x must be an integer or a string 'random'."
Expand Down

0 comments on commit 45171f3

Please sign in to comment.