def test_factory(): # Generate the network & experiment. # This should generally be done in a separate script network = pyphi.examples.basic_network() state = (1, 0, 0) experiment = Experiment('test_factory', '1.0', network, state) experiment.initialize() port = 10030 mechanisms = pyphi.utils.powerset(network.node_indices, nonempty=True) with WorkerFactory(experiment) as factory: start_master(experiment, mechanisms, port) # Load CES ces = experiment.load_ces() print(ces) # Check results reference_ces = pyphi.compute.ces(pyphi.Subsystem(network, state)) assert ces.phis == reference_ces.phis assert ces.mechanisms == reference_ces.mechanisms print('All good!')
def test_simple(): network = pyphi.examples.basic_network() state = (1, 0, 0) experiment = Experiment('test_simple', '1.0', network, state) experiment.initialize() mechanisms = pyphi.utils.powerset(network.node_indices, nonempty=True) print('Starting worker...') worker = subprocess.Popen([ 'work_queue_worker', '-N', experiment.project_name, '-P', experiment.password_file, # '-d', 'all' ]) try: print('Starting master...') start_master(experiment, mechanisms, port=10021, timeout=0, n_divisions=2) except: raise finally: print('Killing worker...') worker.kill() worker.wait() print('Done.') ces = experiment.load_ces() print(ces) reference_ces = pyphi.compute.ces(pyphi.Subsystem(network, state)) assert ces.phis == reference_ces.phis assert ces.mechanisms == reference_ces.mechanisms print('All good!')
#print(inpt,'\n',sw,'\n',swN, '\n''------''\n') V = 0 for v in range(0, nN): V = V + istate[v] * 2**v tpm[int(V)] = tuple(swN) # Create the connectivity matrix cm = np.abs(np.where(weights != 0, 1, 0)) # Transpose our (receiving, sending) CM to use the PyPhi convention of (sending, recieving) cm = np.transpose(cm) # Create the network subsystem_labels = ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T') network = pyphi.Network(tpm, cm, subsystem_labels) # In[5]: # Set state and create subsystem #A B C D E F G H I J K L M N O P Q R S T# state = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) subsystem = pyphi.Subsystem(network, state, range(network.size)) A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T = subsystem.node_indices pyphi.config.REPR_VERBOSITY = 1 experiment = Experiment('largepyr', '2.1', network, state) experiment.initialize()