Closed bannanc closed 6 years ago
Note, I'm intentionally sharing the failing version of this code, otherwise the PR is the same as #24 so there is no need to do code review.
Daniel and I discussed this a little on Slack, I'm going to go ahead and close this PR, because I think I have the resources for how to set the __eq__
and __hash__
functions if I need to.
This pull request is just a demonstration of what happens when I include a
__eq__
function in myAtomStorage
objects in either theChemPerGraph
s orClusterGraph
s.It seems that by overriding the default
__eq__
function makes theAtomStorage
object unhashable meaning it can't be used as the node in a networkx graph. I'd like to understand better why setting that function makes a class unhashable. Is there a better way to handle the nodes in graphs so a nonhashable object could be stored in them.Here is a mini example of what happens when you put a custom class in a networkx graph node. First with no
__eq__
function:prints
['a']
Then when I add an
__eq__
function:at the
graph.add_node(a)
line I get this output: