-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
It's not a big deal for now but ultimately we'll want to be able to set seeds for the rewiring algorithms. I see a few possibilities for this:
- Use the standard library's
random, and set the seed usingrandom.seed($SEED). I don't like this because it mutates global state. - Use numpy's
Generatorobject. This is probably preferable but a bit heavy (and tricky for users). - Add a parameter for passing a random seed at initialization, store a
random.Randomas an attribute, and call that to generate random numbers. - Do the same, with a
np.random.Generator.
I think #3 could look like the following:
class BaseRewirer:
<...>
def __init__(seed: Optional[int] = None):
self.rand = random.Random(seed)
<...>
def rewire(self, G, **kwargs):
# selecting a random edge
rand_edge = rand.choice(list(G.edges))
<...>The challenge with using np.random.Generator is that numpy randomness wants to return arrays, which we don't always want (e.g., when sampling edges).
Metadata
Metadata
Assignees
Labels
No labels