Пример #1
0
    def test_attractor_lengths(self):
        for code in [30, 110, 21, 43]:
            for size in range(2, 7):
                net = ECA(code, size)
                lengths = list(map(len, net.attractors))
                net.clear_landscape()
                self.assertEqual(lengths, list(net.attractor_lengths))

        for net in [s_pombe, s_cerevisiae, c_elegans]:
            lengths = list(map(len, net.attractors))
            net.clear_landscape()
            self.assertEqual(lengths, list(net.attractor_lengths))
Пример #2
0
    def test_in_degree(self):
        for code in [30, 110, 21, 43]:
            for size in range(2, 7):
                net = ECA(code, size)
                in_degrees = np.empty(net.volume, dtype=np.int)
                for i in range(net.volume):
                    in_degrees[i] = np.count_nonzero(
                        net.transitions == i)
                net.clear_landscape()
                self.assertEqual(list(in_degrees), list(net.in_degrees))

        for net in [s_pombe, s_cerevisiae, c_elegans]:
            in_degrees = np.empty(net.volume, dtype=np.int)
            for i in range(net.volume):
                in_degrees[i] = np.count_nonzero(net.transitions == i)
            net.clear_landscape()
            self.assertEqual(list(in_degrees), list(net.in_degrees))
Пример #3
0
    def test_recurrence_times(self):
        for code in [30, 110, 21, 43]:
            for size in range(2, 7):
                net = ECA(code, size)
                recurrence_times = [0] * net.volume
                for i in range(net.volume):
                    b = net.basins[i]
                    recurrence_times[i] = net.heights[i] + \
                        net.attractor_lengths[b] - 1
                net.clear_landscape()
                self.assertEqual(recurrence_times, list(
                    net.recurrence_times))

        for net in [s_pombe, s_cerevisiae, c_elegans]:
            recurrence_times = [0] * net.volume
            for i in range(net.volume):
                b = net.basins[i]
                recurrence_times[i] = net.heights[i] + \
                    net.attractor_lengths[b] - 1
            net.clear_landscape()
            self.assertEqual(recurrence_times, list(
                net.recurrence_times))
Пример #4
0
    def test_heights(self):
        for code in [30, 110, 21, 43]:
            for size in range(2, 7):
                net = ECA(code, size)
                heights = [0] * net.volume
                for i in range(net.volume):
                    b = net.basins[i]
                    state = i
                    while state not in net.attractors[b]:
                        heights[i] += 1
                        state = net.transitions[state]
                net.clear_landscape()
                self.assertEqual(heights, list(net.heights))

        for net in [s_pombe, s_cerevisiae, c_elegans]:
            heights = [0] * net.volume
            for i in range(net.volume):
                b = net.basins[i]
                state = i
                while state not in net.attractors[b]:
                    heights[i] += 1
                    state = net.transitions[state]
            net.clear_landscape()
            self.assertEqual(heights, list(net.heights))