sacs-epfl / decentralizepy

A decentralized learning research framework
MIT License
26 stars 21 forks source link

Fix random neighbors selection for Python >= 3.9 #13

Open Alexyyym opened 7 months ago

Alexyyym commented 7 months ago

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:

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