dimanche 2 juin 2019

numpy random choice and lists of networkx Graphs

So, I want to do some reproducible stochastic simulations that I can share with others, for which I need to create a random state in numpy, using RS = np.random.RandomState(seed). So far so good.

But in my case, I may want to be able to choose a graph from a list.

import networkx as nx
import numpy as np

G = nx.Graph()
L = [G]
np.random.choice(L)
> mtrand.pyx in mtrand.RandomState.choice()
> ValueError: a must be 1-dimensional 

This works with random (as opposed to np.random), but I see suggestions that random may not give consistent results across different systems, even with the same seed.

Is there anything I can do to get numpy's random choice to work?




Aucun commentaire:

Enregistrer un commentaire