Ejemplo n.º 1
0
def test_big_mip_single_node(s_single, flushcache, restore_fs_cache):
    flushcache()
    initial_option = constants.SINGLE_NODES_WITH_SELFLOOPS_HAVE_PHI
    constants.SINGLE_NODES_WITH_SELFLOOPS_HAVE_PHI = True
    assert compute.big_mip(s_single).phi == 0.5
    constants.SINGLE_NODES_WITH_SELFLOOPS_HAVE_PHI = False
    assert compute.big_mip(s_single).phi == 0.0
    constants.SINGLE_NODES_WITH_SELFLOOPS_HAVE_PHI = initial_option
Ejemplo n.º 2
0
def test_big_mip_single_node(s_single, flushcache, restore_fs_cache):
    flushcache()
    initial_option = config.SINGLE_NODES_WITH_SELFLOOPS_HAVE_PHI
    config.SINGLE_NODES_WITH_SELFLOOPS_HAVE_PHI = True
    assert compute.big_mip(s_single).phi == 0.5
    config.SINGLE_NODES_WITH_SELFLOOPS_HAVE_PHI = False
    assert compute.big_mip(s_single).phi == 0.0
    config.SINGLE_NODES_WITH_SELFLOOPS_HAVE_PHI = initial_option
Ejemplo n.º 3
0
def test_big_mip_wrappers(reducible, flushcache, restore_fs_cache):
    flushcache()
    assert (compute.big_mip(reducible) ==
            models.BigMip(subsystem=reducible, cut_subsystem=reducible,
                          phi=0.0, unpartitioned_constellation=[],
                          partitioned_constellation=[]))
    assert compute.big_phi(reducible) == 0.0
Ejemplo n.º 4
0
def test_big_mip_wrappers(reducible, flushcache, restore_fs_cache):
    flushcache()
    assert (compute.big_mip(reducible) ==
            models.BigMip(subsystem=reducible, cut_subsystem=reducible,
                          phi=0.0, unpartitioned_constellation=[],
                          partitioned_constellation=[]))
    assert compute.big_phi(reducible) == 0.0
Ejemplo n.º 5
0
def test_big_mip_empty_subsystem(s_empty, flushcache, restore_fs_cache):
    flushcache()
    assert (compute.big_mip(s_empty) ==
            models.BigMip(phi=0.0,
                          unpartitioned_constellation=[],
                          partitioned_constellation=[],
                          subsystem=s_empty,
                          cut_subsystem=s_empty))
Ejemplo n.º 6
0
def test_big_mip_empty_subsystem(s_empty, flushcache, restore_fs_cache):
    flushcache()
    assert (compute.big_mip(s_empty) ==
            models.BigMip(phi=0.0,
                          unpartitioned_constellation=(),
                          partitioned_constellation=(),
                          subsystem=s_empty,
                          cut_subsystem=s_empty))
Ejemplo n.º 7
0
def test_big_mip_standard_example_sequential(s, flushcache, restore_fs_cache):
    flushcache()
    initial = constants.PARALLEL_CUT_EVALUATION
    constants.PARALLEL_CUT_EVALUATION = False

    mip = compute.big_mip(s)
    check_mip(mip, standard_answer)

    constants.PARALLEL_CUT_EVALUATION = initial
Ejemplo n.º 8
0
def test_big_mip_standard_example_parallel(s, flushcache, restore_fs_cache):
    flushcache()
    initial = (constants.PARALLEL_CUT_EVALUATION, constants.NUMBER_OF_CORES)
    constants.PARALLEL_CUT_EVALUATION, constants.NUMBER_OF_CORES = True, -2

    mip = compute.big_mip(s)
    check_mip(mip, standard_answer)

    constants.PARALLEL_CUT_EVALUATION, constants.NUMBER_OF_CORES = initial
Ejemplo n.º 9
0
def test_expand_cause_repertoire(micro_s_all_off):
    mip = big_mip(micro_s_all_off)
    A = mip.unpartitioned_constellation[0]
    cause = A.cause.mip.unpartitioned_repertoire

    assert np.all(abs(A.expand_cause_repertoire(CD) - cause) < EPSILON)
    assert np.all(abs(
        A.expand_cause_repertoire(BCD).flatten(order='F') -
        np.array([1/6 if i < 6 else 0 for i in range(8)])) < EPSILON)
    assert np.all(abs(
        A.expand_cause_repertoire(ABCD).flatten(order='F') -
        np.array([1/12 if i < 12 else 0 for i in range(16)])) < EPSILON)
    assert np.all(abs(A.expand_cause_repertoire(ABCD) -
                      A.expand_cause_repertoire()) < EPSILON)
Ejemplo n.º 10
0
def test_expand_effect_repertoire(micro_s_all_off):
    mip = big_mip(micro_s_all_off)
    A = mip.unpartitioned_constellation[0]
    effect = A.effect.mip.unpartitioned_repertoire

    assert np.all(abs(A.expand_effect_repertoire(CD) - effect) < EPSILON)
    assert np.all(abs(A.expand_effect_repertoire(BCD).flatten(order='F') -
                      np.array([.25725, .23275, .11025, .09975,
                                .11025, .09975, .04725, .04275])) < EPSILON)
    assert np.all(abs(
        A.expand_effect_repertoire(ABCD).flatten(order='F') -
        np.array([.13505625, .12219375, .12219375, .11055625,
                  .05788125, .05236875, .05236875, .04738125,
                  .05788125, .05236875, .05236875, .04738125,
                  .02480625, .02244375, .02244375, .02030625])) < EPSILON)
    assert np.all(abs(A.expand_effect_repertoire(ABCD) -
                      A.expand_effect_repertoire()) < EPSILON)
Ejemplo n.º 11
0
def test_expand_cause_repertoire(micro_s_all_off):
    mip = big_mip(micro_s_all_off)
    A = mip.unpartitioned_constellation[0]
    cause = A.cause.mip.unpartitioned_repertoire

    assert np.all(abs(A.expand_cause_repertoire(CD) - cause) < EPSILON)
    assert np.all(
        abs(
            A.expand_cause_repertoire(BCD).flatten(order='F') -
            np.array([1 / 6 if i < 6 else 0 for i in range(8)])) < EPSILON)
    assert np.all(
        abs(
            A.expand_cause_repertoire(ABCD).flatten(order='F') -
            np.array([1 / 12 if i < 12 else 0 for i in range(16)])) < EPSILON)
    assert np.all(
        abs(A.expand_cause_repertoire(ABCD) -
            A.expand_cause_repertoire()) < EPSILON)
Ejemplo n.º 12
0
def test_expand_effect_repertoire(micro_s_all_off):
    mip = big_mip(micro_s_all_off)
    A = mip.unpartitioned_constellation[0]
    effect = A.effect.mip.unpartitioned_repertoire

    assert np.all(abs(A.expand_effect_repertoire(CD) - effect) < EPSILON)
    assert np.all(
        abs(
            A.expand_effect_repertoire(BCD).flatten(order='F') - np.array([
                .25725, .23275, .11025, .09975, .11025, .09975, .04725, .04275
            ])) < EPSILON)
    assert np.all(
        abs(
            A.expand_effect_repertoire(ABCD).flatten(order='F') - np.array([
                .13505625, .12219375, .12219375, .11055625, .05788125,
                .05236875, .05236875, .04738125, .05788125, .05236875,
                .05236875, .04738125, .02480625, .02244375, .02244375,
                .02030625
            ])) < EPSILON)
    assert np.all(
        abs(A.expand_effect_repertoire(ABCD) -
            A.expand_effect_repertoire()) < EPSILON)
Ejemplo n.º 13
0
def test_big_mip_disconnected_network(reducible, flushcache, restore_fs_cache):
    flushcache()
    assert (compute.big_mip(reducible) ==
            models.BigMip(subsystem=reducible, cut_subsystem=reducible,
                          phi=0.0, unpartitioned_constellation=[],
                          partitioned_constellation=[]))
Ejemplo n.º 14
0
def test_big_mip_complete_graph_standard_example(s_complete):
    mip = compute.big_mip(s_complete)
    check_mip(mip, standard_answer)
Ejemplo n.º 15
0
def test_big_mip_complete_graph_s_noised(s_noised_complete):
    mip = compute.big_mip(s_noised_complete)
    check_mip(mip, noised_answer)
Ejemplo n.º 16
0
def test_big_mip_complete_graph_standard_example(s_complete):
    mip = compute.big_mip(s_complete)
    check_mip(mip, standard_answer)
Ejemplo n.º 17
0
def test_big_mip_disconnected_network(reducible, flushcache, restore_fs_cache):
    flushcache()
    assert (compute.big_mip(reducible) ==
            models.BigMip(subsystem=reducible, cut_subsystem=reducible,
                          phi=0.0, unpartitioned_constellation=[],
                          partitioned_constellation=[]))
Ejemplo n.º 18
0
def test_big_mip_complete_graph_big_subsys_all(big_subsys_all_complete):
    mip = compute.big_mip(big_subsys_all_complete)
    check_mip(mip, big_answer)
Ejemplo n.º 19
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from pyphi.compute import big_mip
from pyphi import Subsystem
import numpy as np
import example_networks
from pyphi.constants import EPSILON

micro = example_networks.micro()
micro.current_state = (0, 0, 0, 0)
micro.past_state = (0, 0, 0, 0)
micro_subsystem = Subsystem(range(micro.size), micro)
mip = big_mip(micro_subsystem)

CD = micro_subsystem.nodes[2:4]
BCD = micro_subsystem.nodes[1:4]
ABCD = micro_subsystem.nodes[0:4]

A = mip.unpartitioned_constellation[0]

cause = A.cause.mip.unpartitioned_repertoire
effect = A.effect.mip.unpartitioned_repertoire


def test_expand_cause_repertoire():
    assert np.all(abs(A.expand_cause_repertoire(CD) - cause) < EPSILON)
    assert np.all(
        abs(
            A.expand_cause_repertoire(BCD).flatten(order='F') -
            np.array([1 / 6 if i < 6 else 0 for i in range(8)])) < EPSILON)
Ejemplo n.º 20
0
def test_big_mip_macro(macro_s, flushcache, restore_fs_cache):
    flushcache()
    mip = compute.big_mip(macro_s)
    check_mip(mip, macro_answer)
Ejemplo n.º 21
0
def test_big_mip_big_network_0_thru_3(big_subsys_0_thru_3, flushcache,
                                      restore_fs_cache):
    flushcache()
    mip = compute.big_mip(big_subsys_0_thru_3)
    check_mip(mip, big_subsys_0_thru_3_answer)
Ejemplo n.º 22
0
def test_big_mip_big_network(big_subsys_all, flushcache, restore_fs_cache):
    flushcache()
    mip = compute.big_mip(big_subsys_all)
    check_mip(mip, big_answer)
Ejemplo n.º 23
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from pyphi.compute import big_mip
from pyphi import Subsystem
import numpy as np
import example_networks
from pyphi.constants import EPSILON

micro = example_networks.micro()
micro.current_state = (0, 0, 0, 0)
micro.past_state = (0, 0, 0, 0)
micro_subsystem = Subsystem(range(micro.size), micro)
mip = big_mip(micro_subsystem)

CD = micro_subsystem.nodes[2:4]
BCD = micro_subsystem.nodes[1:4]
ABCD = micro_subsystem.nodes[0:4]

A = mip.unpartitioned_constellation[0]

cause = A.cause.mip.unpartitioned_repertoire
effect = A.effect.mip.unpartitioned_repertoire


def test_expand_cause_repertoire():
    assert np.all(abs(A.expand_cause_repertoire(CD) - cause) < EPSILON)
    assert np.all(abs(
        A.expand_cause_repertoire(BCD).flatten(order='F') -
        np.array([1/6 if i < 6 else 0 for i in range(8)])) < EPSILON)
    assert np.all(abs(
Ejemplo n.º 24
0
def test_big_mip_big_network_0_thru_3(big_subsys_0_thru_3, flushcache,
                                      restore_fs_cache):
    flushcache()
    mip = compute.big_mip(big_subsys_0_thru_3)
    check_mip(mip, big_subsys_0_thru_3_answer)
Ejemplo n.º 25
0
def test_big_mip_complete_graph_rule152_s(rule152_s_complete):
    mip = compute.big_mip(rule152_s_complete)
    check_mip(mip, rule152_answer)
Ejemplo n.º 26
0
def test_big_mip_complete_graph_s_noised(s_noised_complete):
    mip = compute.big_mip(s_noised_complete)
    check_mip(mip, noised_answer)
Ejemplo n.º 27
0
def test_big_mip_complete_graph_rule152_s(rule152_s_complete):
    mip = compute.big_mip(rule152_s_complete)
    check_mip(mip, rule152_answer)
Ejemplo n.º 28
0
def test_big_mip_complete_graph_big_subsys_all(big_subsys_all_complete):
    mip = compute.big_mip(big_subsys_all_complete)
    check_mip(mip, big_answer)
Ejemplo n.º 29
0
def test_big_mip_rule152(rule152_s, flushcache, restore_fs_cache):
    flushcache()
    mip = compute.big_mip(rule152_s)
    check_mip(mip, rule152_answer)
Ejemplo n.º 30
0
def test_big_mip_big_network(big_subsys_all, flushcache, restore_fs_cache):
    flushcache()
    mip = compute.big_mip(big_subsys_all)
    check_mip(mip, big_answer)
Ejemplo n.º 31
0
def test_jsonify_big_mip(s, flushcache, restore_fs_cache):
    flushcache()
    jsonify.loads(jsonify.dumps(compute.big_mip(s)))
Ejemplo n.º 32
0
def test_big_mip_rule152(rule152_s, flushcache, restore_fs_cache):
    flushcache()
    mip = compute.big_mip(rule152_s)
    check_mip(mip, rule152_answer)
Ejemplo n.º 33
0
def test_big_mip_single_node_selfloops_dont_have_phi(s_single, flushcache,
                                                     restore_fs_cache):
    flushcache()
    assert compute.big_mip(s_single).phi == 0.0