wmayner / pyphi

A toolbox for integrated information theory.
https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1006343
Other
372 stars 97 forks source link

concept_caching error #9

Closed freckletonj closed 8 years ago

freckletonj commented 9 years ago

Hey Will, or whoever else :)

I'm trying to get caching working, and I've noticed a curious bug in the following code:

    XOR =  lambda xs: sum(xs) == 1

    nodes = [XOR, XOR, XOR]

    current_state = (1, 0, 0)

    past_state = ((0,))*len(current_state)

    cm = [[1,1,1],
          [1,0,1],
          [1,1,1]]

    tpm = get_tpm(nodes, cm) #(my function for generating a tpm)

    network = pyphi.Network(tpm, current_state, past_state, connectivity_matrix=cm)

    main_complex = pyphi.compute.main_complex(network)

Error:

...
File "/home/josh/.virtualenvs/IITipython3/lib/python3.4/site-packages/pyphi/concept_caching.py", line 276, in __init__
    self.mechanism)
  File "/home/josh/.virtualenvs/IITipython3/lib/python3.4/site-packages/pyphi/concept_caching.py", line 246, in _normalize_mice
    mice.purview, mice.repertoire, normalized_indices)
  File "/home/josh/.virtualenvs/IITipython3/lib/python3.4/site-packages/pyphi/concept_caching.py", line 221, in _normalize_purview_and_repertoire
    purview = sorted(purview)
TypeError: 'NoneType' object is not iterable

This error only occurs when the network isn't fully connected (including self-connections). If you replace the 0 with a 1 in the connection matrix, all works as planned.

I'm using the pyphi version from pip install pyphi.

Any thoughts?

wmayner commented 9 years ago

Hi there,

Welcome to the project! Sadly, the concept caching module is pretty much abandoned and definitely broken. I stopped working on it a while ago, and the rest of the code has been changed enough that we should probably scrap it entirely.

That should really be made clear in the documentation—sorry about that. If you disable concept caching in the config, you should be all set. Note that BigMip caching does work, however.

PRs are obviously welcome and greatly appreciated, though concept caching in general is a hard problem, both in implementation difficulty and in time complexity (finding equivalent concepts is at least as hard as the graph isomorphism problem). If you're looking for somewhere to contribute, you can get in touch with me directly at <my last name> at wisc dot edu.

Glad to see someone else taking a look at the code!

Cheers, Will

rlmv commented 8 years ago

Concept caching is now disabled and removed from the default config so I'm going to close this.