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

Fix random neighbors selection for Python >= 3.9 #13

Open
Alexyyym opened this issue Apr 8, 2024 · 0 comments
Open

Fix random neighbors selection for Python >= 3.9 #13

Alexyyym opened this issue Apr 8, 2024 · 0 comments

Comments

@Alexyyym
Copy link

Alexyyym commented Apr 8, 2024

In node classes that implement a random selection between their neighbors (for example EL), the method is defined as follows:

def get_neighbors(self, node=None):
    return set(self.rng.sample(self.my_neighbors, self.degree))

With:

  • self.rng being the Random library.
  • self.my_neighbors being a set of neighbors.

For Python >=3.9, the method Random.sample() is deprecated for sets. According to the documentation, "In the future, the population must be a sequence. Instances of set are no longer supported. The set must first be converted to a list or tuple, preferably in a deterministic order so that the sample is reproducible."

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