Skip to content

TypeError in Chain.communication_classes() #22

@rdbliss

Description

@rdbliss

When running Chain.communication_classes(), a TypeError is thrown: TypeError: unhashable type: 'set'.

The issue seems to be having nested sets, since the interior sets are mutable. One fix would be to use frozenset() for the nested sets. Alternatively, the return could be changed to a list of sets, nested lists, or something similar.

Exact error:

In [1]: run pykov.py

In [2]: Chain({(0, 1): 1, (1, 0): 1}).communication_classes()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-cc5c171ee32c> in <module>()
----> 1 Chain({(0, 1): 1, (1, 0): 1}).communication_classes()

/home/rwb/python/Pykov/pykov.py in communication_classes(self)
   1347                 if row[0, el] == 1:
   1348                     comm_class.add(pos2el[el])
-> 1349             res.add(comm_class)
   1350         return res
   1351 

TypeError: unhashable type: 'set'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions