-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
ContinuousSpaceAgent.pos assignment does not update position #3399
Copy link
Copy link
Closed
Description
Describe the bug
ContinuousSpaceAgent exposes a pos property. The getter returns self.position, but the setter is currently a no-op (pass). As a result, assigning agent.pos = ... silently does nothing, which can lead to confusing behavior and unnecessary debugging
Expected behavior
pos should behave as a true alias for position: setting agent.pos = value should update agent.position and preserve existing torus correction.
To Reproduce
import numpy as np
from mesa import Model
from mesa.experimental.continuous_space import ContinuousSpace, ContinuousSpaceAgent
m = Model(rng=42)
space = ContinuousSpace(np.asarray([[0, 1], [0, 1]]), torus=False, random=m.random)
a = ContinuousSpaceAgent(space, m)
a.position = [0.2, 0.2]
a.pos = [0.7, 0.7] # currently a silent no-op
assert np.allclose(a.position, [0.7, 0.7]) # fails
Additional context
Low severity (workaround is using agent.position directly), but the silent no-op is surprising and easy to miss.
Added regression coverage in tests/experimental/test_continuous_space.py
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels