예제 #1
0
    def testFilterSortedSegmentsByCell(self):
        """
        Test that segments are filtered by cell.
        """
        connections = Connections(20, 0.2)
        segments = [connections.createSegment(i, 1) for i in range(19, -1, -1)]
        self.assertEqual(list(range(20)), segments,
                         "Segments were not allocated continuously")

        sorted_segments = connections.sortSegmentsByCell(np.array(segments))
        segments_should_be = [19, 10, 0]  # Segment 19 belongs to cell 0, etc.
        filtered_segments = list(
            connections.filterSegmentsByCell(sorted_segments, [0, 9, 19],
                                             True))
        self.assertEqual(segments_should_be, filtered_segments,
                         "Segments were not filtered correctly")
예제 #2
0
    def testSortSegmentsByCell(self):
        """
        Test that segments are sorted by cell.
        """
        connections = Connections(20, 0.2)
        segments = [connections.createSegment(i, 1) for i in range(19, -1, -1)]
        self.assertEqual(list(range(20)), segments,
                         "Segments were not allocated continuously")

        segments_should_be = list(range(
            19, -1, -1))  # Segment 19 belongs to cell 0, etc.
        shuffle(segments)
        sorted_segments = list(
            connections.sortSegmentsByCell(np.array(segments)))
        self.assertEqual(segments_should_be, sorted_segments,
                         "Segments were not sorted by cell")