def test_attractors(): params = Parameters(seed=4, cis_count=2, reg_channels=5, out_channels=2, cue_channels=3,) world = World(params) factory = Factory(world) net = factory.create_network() alens = [len(a) for a in net.attractors] print alens print net.attractors_size
def test_network_pickle(): params = Parameters(seed=4, cis_count=2, reg_channels=5, out_channels=2, cue_channels=3,) world = World(params) factory = Factory(world) n1 = factory.create_network() out = pickle.dumps(n1, -1) n2 = pickle.loads(out) for g1, g2 in zip(n1.genes, n2.genes): assert g1.pub == g2.pub for m1, m2 in zip(g1.modules, g2.modules): assert m1.same_as(m2)
def test_neighbourhood(): # Note we use the PROGRESSIVE mutation as this guarantees a change! params = Parameters(seed=4, cis_count=2, reg_channels=5, out_channels=2, cue_channels=3, mutate_type=MutateType.PROGRESSIVE) world = World(params) const = Factory(world) net = const.create_network() base_bnd = get_binding_values(const, net) # This should just take 1 step neighbours nayb = NetworkNeighbourhood(net, 1000) npformat = const.to_numpy(nayb.neighbours) # Get all of the bindings out bnd = npformat['binding'] for b in bnd: # There should be just one difference! assert (base_bnd != b.ravel()).sum() == 1