Skip to content
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

Inconsistency in get_neighbors Method Parameters for NetworkGrid in Mesa 2.2.4 #2110

Open
chingisdev opened this issue Apr 11, 2024 · 1 comment

Comments

@chingisdev
Copy link

Describe the bug
The get_neighbors method for NetworkGrid as outlined in the Mesa documentation suggests that this method accepts a radius parameter. However, upon inspection and usage in Mesa version 2.2.4, it appears that the radius parameter is not implemented in the get_neighbors method.

Expected behavior
To ensure consistency with the documentation and to facilitate depth-wise traversal or analysis within the graph, it's expected that the get_neighbors method should accept a radius parameter as described in the documentation. This would allow for more flexible and powerful network analyses directly within Mesa models.

To Reproduce

  1. Install Mesa version 2.2.4.
  2. Create a simple model that includes a NetworkGrid.
  3. Attempt to call the get_neighbors method on the grid instance, passing a node ID and a radius value, typically within a model's step method.
  4. Observe that an unexpected argument error is raised due to the absence of the radius parameter.

Example Code:

network_grid = NetworkGrid(some_networkx_graph)
node_id = random.choice(list(some_networkx_graph.nodes))
neighbors = network_grid.get_neighbors(node_id, radius=2)

Additional Context:
Adjusting method signatures to match the documentation can greatly enhance usability and developer experience, especially for those relying on network-based analyses in their agent-based models.

@chingisdev
Copy link
Author

Update: Upon preparing to contribute a fix, I cloned the repository and found that the issue has already been addressed in the codebase. However, these updates are not yet reflected in the latest release version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant