mesa icon indicating copy to clipboard operation
mesa copied to clipboard

document the duplicate coordinate

Open Krishsharma179 opened this issue 8 months ago • 9 comments

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 avatar Mar 07 '26 06:03 Krishsharma179

@Krishsharma179 can i work on this

Rishav23av avatar Mar 07 '26 08:03 Rishav23av

@Rishav23av Thanks !!! for the interest Rishav but i have the implementation and i will send a PR in some time

Krishsharma179 avatar Mar 07 '26 08:03 Krishsharma179

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 avatar Mar 07 '26 15:03 quaquel

@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!

Krishsharma179 avatar Mar 08 '26 00:03 Krishsharma179

I suggest just documenting this explicitly for now.

quaquel avatar Mar 09 '26 16:03 quaquel

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 avatar Mar 17 '26 11:03 DashamiJituri

@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

Rishav23av avatar Mar 17 '26 13:03 Rishav23av

@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.

DashamiJituri avatar Mar 17 '26 15:03 DashamiJituri

fixed via #3473

quaquel avatar Mar 22 '26 09:03 quaquel