Skip to content

Commit

Permalink
Merge branch 'release/0.3.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
wmayner committed Feb 20, 2015
2 parents 412a049 + fb8c1f4 commit 45e2c0d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pyphi/__init__.py
Expand Up @@ -57,7 +57,7 @@
"""

__title__ = 'pyphi'
__version__ = '0.3.7'
__version__ = '0.3.8'
__description__ = 'Python library for computing integrated information.',
__author__ = 'Will Mayner'
__author_email__ = 'wmayner@gmail.com'
Expand Down
11 changes: 6 additions & 5 deletions pyphi/compute.py
Expand Up @@ -330,16 +330,17 @@ def time_annotated(big_mip, small_phi_time=0.0):
else:
# Sequentially loop over all partitions, holding only two BigMips in
# memory at once.
min_phi, min_mip = float('inf'), _null_mip(subsystem)
min_mip = _null_mip(subsystem)
min_mip.phi = float('inf')
for i, partition in enumerate(bipartitions):
new_mip = _evaluate_partition(
subsystem, partition, unpartitioned_constellation)
log.debug("Finished {} of {} partitions.".format(
i + 1, len(bipartitions)))
if new_mip.phi < min_phi:
min_phi, min_mip = new_mip.phi, new_mip
# Stop as soon as we find a MIP with effectively 0 phi.
if min_phi < constants.EPSILON:
if new_mip < min_mip:
min_mip = new_mip
# Short-circuit as soon as we find a MIP with effectively 0 phi.
if not min_mip:
break
return time_annotated(min_mip, small_phi_time)

Expand Down
10 changes: 3 additions & 7 deletions pyphi/models.py
Expand Up @@ -545,7 +545,7 @@ def __eq__(self, other):
def __bool__(self):
"""A BigMip is truthy if it is not reducible; i.e. if it has a
significant amount of |big_phi|."""
return self.phi > constants.EPSILON
return self.phi >= constants.EPSILON

def __hash__(self):
return hash((self.phi, self.unpartitioned_constellation,
Expand All @@ -558,9 +558,7 @@ def __hash__(self):
def __lt__(self, other):
if _phi_eq(self, other):
if len(self.subsystem) == len(other.subsystem):
# Compare actual Phi values up to maximum precision, for
# more determinism in things like max and min
return self.phi < other.phi
return False
else:
return len(self.subsystem) < len(other.subsystem)
else:
Expand All @@ -569,9 +567,7 @@ def __lt__(self, other):
def __gt__(self, other):
if _phi_eq(self, other):
if len(self.subsystem) == len(other.subsystem):
# Compare actual Phi values up to maximum precision, for
# more determinism in things like max and min
return self.phi > other.phi
return False
else:
return len(self.subsystem) > len(other.subsystem)
else:
Expand Down
33 changes: 24 additions & 9 deletions test/test_big_phi.py
Expand Up @@ -156,7 +156,7 @@
(0, 1): 0.34811,
(2, 3): 0.34811,
},
'cut': models.Cut(severed=(1, 3), intact=(0, 2))
'cut': models.Cut(severed=(0, 2), intact=(1, 3))
}


Expand Down Expand Up @@ -423,35 +423,50 @@ def test_rule152_complexes_no_caching(rule152):
assert main.cut == result['cut']


def test_big_mip_micro(micro_s, flushcache, restore_fs_cache):
def test_big_mip_micro_parallel(micro_s, flushcache, restore_fs_cache):
flushcache()

initial = config.PARALLEL_CUT_EVALUATION
config.PARALLEL_CUT_EVALUATION = True

mip = compute.big_mip(micro_s)
check_mip(mip, micro_answer)

config.PARALLEL_CUT_EVALUATION = initial


def test_big_mip_micro_sequential(micro_s, flushcache, restore_fs_cache):
flushcache()

initial = config.PARALLEL_CUT_EVALUATION
config.PARALLEL_CUT_EVALUATION = False

mip = compute.big_mip(micro_s)
check_mip(mip, micro_answer)

config.PARALLEL_CUT_EVALUATION = initial


@pytest.mark.filter
def test_big_mip_macro(macro_s, flushcache, restore_fs_cache):
flushcache()
mip = compute.big_mip(macro_s)
check_mip(mip, macro_answer)


def test_strongly_connected():
# A disconnected matrix
# A disconnected matrix.
cm1 = np.array([[0, 0, 1],
[0, 1, 0],
[1, 0, 0]])
# A strongly connected matrix
# A strongly connected matrix.
cm2 = np.array([[0, 1, 0],
[0, 0, 1],
[1, 0, 0]])
# A weakly connected matrix
# A weakly connected matrix.
cm3 = np.array([[0, 1, 0],
[0, 0, 1],
[0, 1, 0]])
assert connected_components(csr_matrix(cm1), connection='strong')[0] > 1
assert connected_components(csr_matrix(cm2), connection='strong')[0] == 1
assert connected_components(csr_matrix(cm3), connection='strong')[0] > 1




0 comments on commit 45e2c0d

Please sign in to comment.