def hash_gates_and_simulation(biosystem):
    """
    Hash gates and simulation
    """
    hash_lst = []
    for i in range(len(biosystem['nodes'])):
        hash_str = dump_ord(biosystem['simulation_parameters'][i])
        hash_lst.append(hash('"%s":%s' % (biosystem['nodes'][i], hash_str)))
    return hash_lst
 def __init__(self, biosystem):
     self.vertex = self.reconstruct_arcs(biosystem)
     if DEBUG:
         print debug_info('reconstructed_arcs'), self.vertex
     self.reaction_lines = []
     self.resolve_biosystem_net(self.vertex)
     if DEBUG:
         print debug_info('BioNetwork_lines'), self.reaction_lines
     self.reaction_lines_hash = hash_list(self.reaction_lines)
     if DEBUG:
         print debug_info('BioNetwork_lines_hash'), self.reaction_lines_hash
     self.network_hash = hash(dump_ord(sorted(self.reaction_lines_hash))) + biosystem['system_parameter']['time']
     if DEBUG:
         print debug_info('BioNetwork_hash'), self.network_hash
from debug_tool import debug_info
from hash_tool import dump_ord
from django.test import TestCase


if __name__ == "__main__":
    # This can be used as unittest, for if it failed on a certain python version, you cannot use the module safely.
    # --------------------------------------------------------
    # This shows True, for python will check the dict recurrently and ignore the order.
    dict1 = {"0": (3.1416, "0:T~1", {"0:T~2I0": 1, "b": 3.14}), "1": "c1"}
    dict2 = {"1": "c1", "0": (3.1416, "0:T~1", {"b": 3.14, "0:T~2I0": 1})}
    print dict1 == dict2
    # This shows False, for the order of items in the list are very important
    list1 = [1, 3]
    list2 = [3, 1]
    print list1 == list2
    # Set, ignore the order but may change the count. (True)
    print set(list1) == set(list2)
    # There never seems to be a hash for a dict (None). Nasty!
    print dict1.__hash__
    # Just dump it in order. Important.
    print dump_ord(biosystem_sample1)
    # Emm... So I only have to json-hash it, right?
    print hash_gates_and_simulation(biosystem_sample1)

    print compare_biosystem(biosystem_sample1, biosystem_sample2)
else:
    class TestReaction(TestCase):
        def test(self):
            self.assertEqual(compare_biosystem(biosystem_sample1, biosystem_sample2), True)