document the duplicate coordinate
Summary In the current system in discrete_space.py in add_cell there is a probability that the user might initialize the new cell at the coordinate where there is already a cell then the previous cell will be overwritten by the new cell silently
Implementation Just document this explicitly
Warning:
Coordinate Collision: If a cell already exists at the specified
coordinates (e.g., cell1), it will be overwritten silently by the
new cell (cell2).
Ensure the target coordinates are vacant before calling this method.
@Krishsharma179 can i work on this
@Rishav23av Thanks !!! for the interest Rishav but i have the implementation and i will send a PR in some time
I am not sure whether this is a problem. It might however be documented explicitly.
Why might it not be a problem? Dynamically changing Discrete spaces is conceptually possible but not actively supported by Mesa. So the default use is to instantiate a space with cells and then leave it as is afterwards. Thus, it is unlikely that this condition might be triggered.
If we want to do something with it, I am not sure what the right solution would be. Raising an exception is quite extreme. It forces a user to first remove the old cell before adding a new one. A warning, however, also seems strange, because it suggests that what someone is doing is somehow not correct.
@quaquel Thanks for the thoughtful explanation!
I understand that this case might have a lower chance of occurring, but it can still happen especially for users with less experience.
I agree that raising an error can be extreme, but a Warning could be a good middle ground:
- If a person is doing it intentionally, they can ignore the warning.
- If it's a mistake, the warning alerts them before silent data loss occurs.
That said, I'm happy to proceed with documentation instead if you prefer that approach. Just want to ensure users are aware of this behavior to avoid debugging headaches later!
I suggest just documenting this explicitly for now.
Hi, I’d like to work on documenting this behavior in the relevant method to make it clearer for users.
I plan to add a concise note in the docstring explaining that existing cells at the same coordinates will be overwritten.
Please let me know if this approach looks good.
@DashamiJituri PR #3473 addresses this issue. Please read the issue and if someone open a pr it before commenting. @Krishsharma179,@quaquel you can go ahead and close this issue
@DashamiJituri PR #3473 addresses this issue. Please read the issue and if someone open a pr it before commenting. @Krishsharma179 you can go ahead and close this issue
Thanks for pointing that out, I appreciate it. I’ll make sure to check for existing PRs before commenting on issues next time.
fixed via #3473