Exemplo n.º 1
0
def test_multi_composite() -> None:

    composite1 = Composite()

    processes = {'A': ExchangeA()}
    topology = {'A': {'internal': ('in', ), 'external': ('out', )}}
    composite2 = Composite({
        'processes': processes,
        'topology': topology,
    })

    composite3 = Composite()
    assert not composite3['processes']
    assert not composite3['topology']
    print(f"composite3 processes: {composite3['processes']}")
    print(f"composite3 topology: {composite3['topology']}")

    composite1.merge(composite=composite2, path=(
        'agents',
        '1',
    ))

    composite4 = Composite()
    assert not composite4['processes']
    assert not composite4['topology']
    print(f"composite4 processes: {composite4['processes']}")
    print(f"composite4 topology: {composite4['topology']}")
Exemplo n.º 2
0
def test_process_in_experiment_environment() -> None:
    process = ExchangeA()
    experiment = process_in_experiment(process, settings={'environment': {}})

    assert experiment.processes['process'] is process
    assert isinstance(experiment.processes['nonspatial_environment'],
                      NonSpatialEnvironment)
Exemplo n.º 3
0
    def generate_processes(self, config):
        agent_id = config['agent_id']
        division_config = dict({}, agent_id=agent_id, composer=self)

        return {
            'exchange': ExchangeA(config['exchange']),
            'division': MetaDivision(division_config)
        }
Exemplo n.º 4
0
def test_process_in_experiment_timeline() -> None:
    timeline = [
        (0, {
            ('internal', 'A'): 0
        }),
        (1, {
            ('internal', 'A'): 1
        }),
    ]
    process = ExchangeA()
    experiment = process_in_experiment(
        process, settings={'timeline': {
            'timeline': timeline
        }})
    assert experiment.processes['process'] is process
    assert isinstance(experiment.processes['timeline'], TimelineProcess)
Exemplo n.º 5
0
 def generate_processes(self, config):
     agent_id = config['agent_id']
     return {
         'exchange': ExchangeA(config['exchange']),
         'burst': Burst({'agent_id': agent_id})
     }
Exemplo n.º 6
0
 def generate_processes(self, config):
     death_config = config['death']
     death_config['agent_id'] = config['agent_id']
     return {
         'exchange': ExchangeA(config['exchange']),
         'death': Remove(death_config)}
Exemplo n.º 7
0
 def generate_processes(self, config):
     return {'secrete': ExchangeA(config['secrete'])}
Exemplo n.º 8
0
 def generate_processes(self, config):
     return {
         'exchange': ExchangeA(config['exchange']),
         'death': SwapProcesses(config['death'])
     }
Exemplo n.º 9
0
 def generate_processes(self, config):
     return {
         'exchange': ExchangeA(config['exchange']),
         'engulf': Engulf(config['engulf']),
         'expel': Engulf(config['engulf'])
     }
Exemplo n.º 10
0
def test_process_in_experiment() -> None:
    process = ExchangeA()
    experiment = process_in_experiment(process)
    assert experiment.processes['process'] is process