# Path: wallace/networks.py
# class Chain(Network):
# class FullyConnected(Network):
# class Empty(Network):
# class Star(Network):
# class Burst(Network):
# class DiscreteGenerational(Network):
# class ScaleFree(Network):
# class SequentialMicrosociety(Network):
#     def add_node(self, node):
#     def add_node(self, node):
#     def add_node(self, node):
#     def add_source(self, source):
#     def add_node(self, node):
#     def add_node(self, node):
#     def __init__(self, generations, generation_size, initial_source):
#     def generations(self):
#     def generation_size(self):
#     def initial_source(self):
#     def add_node(self, node):
#     def __init__(self, m0, m):
#     def m0(self):
#     def m(self):
#     def add_node(self, node):
#     def __init__(self, n):
#     def n(self):
#     def add_node(self, node):
# 
# Path: wallace/nodes.py
# class Agent(Node):
# class ReplicatorAgent(Agent):
# class Source(Node):
# class RandomBinaryStringSource(Source):
# class Environment(Node):
#     def fitness(self):
#     def fitness(self, fitness):
#     def fitness(self):
#     def update(self, infos):
#     def _what(self):
#     def create_information(self):
#     def _info_type(self):
#     def _contents(self):
#     def receive(self, what):
#     def _contents(self):
#     def state(self, time=None):
#     def _what(self):
# 
# Path: wallace/db.py
# def sessions_scope(local_session, commit=False):
# def scoped_session_decorator(func):
#     def wrapper(*args, **kwargs):
# def init_db(drop_all=False):
# 
# Path: wallace/models.py
# DATETIME_FMT = "%Y-%m-%dT%H:%M:%S.%f"
# def timenow():
#     def __init__(self, worker_id, assignment_id, hit_id, mode):
#     def __json__(self):
#     def nodes(self, type=None, failed=False):
#     def questions(self, type=None):
#     def infos(self, type=None, failed=False):
#     def fail(self):
#     def __init__(self, participant, question, response, number):
#     def fail(self):
#     def __json__(self):
#     def __repr__(self):
#     def __json__(self):
#     def nodes(self, type=None, failed=False, participant_id=None):
#     def size(self, type=None, failed=False):
#     def infos(self, type=None, failed=False):
#     def transmissions(self, status="all", failed=False):
#     def transformations(self, type=None, failed=False):
#     def latest_transmission_recipient(self):
#     def vectors(self, failed=False):
#     def add_node(self, node):
#     def fail(self):
#     def calculate_full(self):
#     def print_verbose(self):
#     def __init__(self, network, participant=None):
#     def __repr__(self):
#     def __json__(self):
#     def vectors(self, direction="all", failed=False):
#     def neighbors(self, type=None, direction="to", failed=None):
#     def is_connected(self, whom, direction="to", failed=None):
#     def infos(self, type=None, failed=False):
#     def received_infos(self, type=None, failed=None):
#     def transmissions(self, direction="outgoing", status="all", failed=False):
#     def transformations(self, type=None, failed=False):
#     def fail(self):
#     def connect(self, whom, direction="to"):
#     def flatten(self, l):
#     def transmit(self, what=None, to_whom=None):
#     def _what(self):
#     def _to_whom(self):
#     def receive(self, what=None):
#     def update(self, infos):
#     def replicate(self, info_in):
#     def mutate(self, info_in):
#     def __init__(self, origin, destination):
#     def __repr__(self):
#     def __json__(self):
#     def transmissions(self, status="all"):
#     def fail(self):
#     def __init__(self, origin, contents=None):
#     def _write_once(self, key, value):
#     def __repr__(self):
#     def __json__(self):
#     def fail(self):
#     def transmissions(self, status="all"):
#     def transformations(self, relationship="all"):
#     def _mutated_contents(self):
#     def __init__(self, vector, info):
#     def mark_received(self):
#     def __repr__(self):
#     def __json__(self):
#     def fail(self):
#     def __repr__(self):
#     def __init__(self, info_in, info_out):
#     def __json__(self):
#     def fail(self):
# class SharedMixin(object):
# class Participant(Base, SharedMixin):
# class Question(Base, SharedMixin):
# class Network(Base, SharedMixin):
# class Node(Base, SharedMixin):
# class Vector(Base, SharedMixin):
# class Info(Base, SharedMixin):
# class Transmission(Base, SharedMixin):
# class Transformation(Base, SharedMixin):
# class Notification(Base, SharedMixin):


from wallace import networks, nodes, db, models
from nose.tools import assert_raises, raises
import random
        assert len(net.nodes(type=nodes.Agent)) == m0 + 1
        assert len(net.vectors()) == m0*(m0 - 1) + 2*m

        agent2 = nodes.Agent(network=net)
        net.add_node(agent2)
        assert len(net.nodes(type=nodes.Agent)) == m0 + 2
        assert len(net.vectors()) == m0*(m0 - 1) + 2*2*m

    def test_scale_free_repr(self):
        net = networks.ScaleFree(m0=4, m=4)
        self.db.add(net)
        self.db.commit()

        for i in range(6):
            agent = nodes.Agent(network=net)
            net.add_node(agent)

        assert repr(net) == "<Network-" + str(net.id) + "-scale-free with 6 nodes, 28 vectors, 0 infos, 0 transmissions and 0 transformations>"

    def test_create_sequential_microsociety(self):
        """Create a sequential microsociety."""
        net = networks.SequentialMicrosociety(n=3)
        self.db.add(net)
        self.db.commit()

        net.add_node(nodes.RandomBinaryStringSource(network=net))

        agent1 = nodes.Agent(network=net)
        net.add_node(agent1)


# Path: wallace/networks.py
# class Chain(Network):
# class FullyConnected(Network):
# class Empty(Network):
# class Star(Network):
# class Burst(Network):
# class DiscreteGenerational(Network):
# class ScaleFree(Network):
# class SequentialMicrosociety(Network):
#     def add_node(self, node):
#     def add_node(self, node):
#     def add_node(self, node):
#     def add_source(self, source):
#     def add_node(self, node):
#     def add_node(self, node):
#     def __init__(self, generations, generation_size, initial_source):
#     def generations(self):
#     def generation_size(self):
#     def initial_source(self):
#     def add_node(self, node):
#     def __init__(self, m0, m):
#     def m0(self):
#     def m(self):
#     def add_node(self, node):
#     def __init__(self, n):
#     def n(self):
#     def add_node(self, node):
# 
# Path: wallace/nodes.py
# class Agent(Node):
# class ReplicatorAgent(Agent):
# class Source(Node):
# class RandomBinaryStringSource(Source):
# class Environment(Node):
#     def fitness(self):
#     def fitness(self, fitness):
#     def fitness(self):
#     def update(self, infos):
#     def _what(self):
#     def create_information(self):
#     def _info_type(self):
#     def _contents(self):
#     def receive(self, what):
#     def _contents(self):
#     def state(self, time=None):
#     def _what(self):
# 
# Path: wallace/db.py
# def sessions_scope(local_session, commit=False):
# def scoped_session_decorator(func):
#     def wrapper(*args, **kwargs):
# def init_db(drop_all=False):
# 
# Path: wallace/models.py
# DATETIME_FMT = "%Y-%m-%dT%H:%M:%S.%f"
# def timenow():
#     def __init__(self, worker_id, assignment_id, hit_id, mode):
#     def __json__(self):
#     def nodes(self, type=None, failed=False):
#     def questions(self, type=None):
#     def infos(self, type=None, failed=False):
#     def fail(self):
#     def __init__(self, participant, question, response, number):
#     def fail(self):
#     def __json__(self):
#     def __repr__(self):
#     def __json__(self):
#     def nodes(self, type=None, failed=False, participant_id=None):
#     def size(self, type=None, failed=False):
#     def infos(self, type=None, failed=False):
#     def transmissions(self, status="all", failed=False):
#     def transformations(self, type=None, failed=False):
#     def latest_transmission_recipient(self):
#     def vectors(self, failed=False):
#     def add_node(self, node):
#     def fail(self):
#     def calculate_full(self):
#     def print_verbose(self):
#     def __init__(self, network, participant=None):
#     def __repr__(self):
#     def __json__(self):
#     def vectors(self, direction="all", failed=False):
#     def neighbors(self, type=None, direction="to", failed=None):
#     def is_connected(self, whom, direction="to", failed=None):
#     def infos(self, type=None, failed=False):
#     def received_infos(self, type=None, failed=None):
#     def transmissions(self, direction="outgoing", status="all", failed=False):
#     def transformations(self, type=None, failed=False):
#     def fail(self):
#     def connect(self, whom, direction="to"):
#     def flatten(self, l):
#     def transmit(self, what=None, to_whom=None):
#     def _what(self):
#     def _to_whom(self):
#     def receive(self, what=None):
#     def update(self, infos):
#     def replicate(self, info_in):
#     def mutate(self, info_in):
#     def __init__(self, origin, destination):
#     def __repr__(self):
#     def __json__(self):
#     def transmissions(self, status="all"):
#     def fail(self):
#     def __init__(self, origin, contents=None):
#     def _write_once(self, key, value):
#     def __repr__(self):
#     def __json__(self):
#     def fail(self):
#     def transmissions(self, status="all"):
#     def transformations(self, relationship="all"):
#     def _mutated_contents(self):
#     def __init__(self, vector, info):
#     def mark_received(self):
#     def __repr__(self):
#     def __json__(self):
#     def fail(self):
#     def __repr__(self):
#     def __init__(self, info_in, info_out):
#     def __json__(self):
#     def fail(self):
# class SharedMixin(object):
# class Participant(Base, SharedMixin):
# class Question(Base, SharedMixin):
# class Network(Base, SharedMixin):
# class Node(Base, SharedMixin):
# class Vector(Base, SharedMixin):
# class Info(Base, SharedMixin):
# class Transmission(Base, SharedMixin):
# class Transformation(Base, SharedMixin):
# class Notification(Base, SharedMixin):


# Path: tests/test_networks.py
from wallace import networks, nodes, db, models
from nose.tools import assert_raises, raises
import random

        assert len(net.nodes(type=nodes.Agent)) == m0 + 1
        assert len(net.vectors()) == m0*(m0 - 1) + 2*m

        agent2 = nodes.Agent(network=net)
        net.add_node(agent2)
        assert len(net.nodes(type=nodes.Agent)) == m0 + 2
        assert len(net.vectors()) == m0*(m0 - 1) + 2*2*m

    def test_scale_free_repr(self):
        net = networks.ScaleFree(m0=4, m=4)
        self.db.add(net)
        self.db.commit()

        for i in range(6):
            agent = nodes.Agent(network=net)
            net.add_node(agent)

        assert repr(net) == "<Network-" + str(net.id) + "-scale-free with 6 nodes, 28 vectors, 0 infos, 0 transmissions and 0 transformations>"

    def test_create_sequential_microsociety(self):
        """Create a sequential microsociety."""
        net = networks.SequentialMicrosociety(n=3)
        self.db.add(net)
        self.db.commit()

        net.add_node(nodes.RandomBinaryStringSource(network=net))

        agent1 = nodes.Agent(network=net)
        net.add_node(agent1)


        agent2 = nodes.Agent(network=net)