Skip to content

Fix random neighbors selection for Python >= 3.9 #13

@Alexyyym

Description

@Alexyyym

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions