예제 #1
0
 def test_order_sets_chunk_count_descending(self):
     for _ in range(10):
         sets = make_random_sets()
         _, composition_matrix = _get_ordered_chunks_and_composition_array(sets, sets_ordering='chunk count')
         chunk_counts = composition_matrix.sum(1)
         chunk_counts_descending = is_ascending(chunk_counts[::-1])
         self.assertTrue(chunk_counts_descending)
예제 #2
0
 def test_order_chunks_occurence_descending(self):
     for _ in range(10):
         sets = make_random_sets()
         _, composition_matrix = _get_ordered_chunks_and_composition_array(sets, chunks_ordering='occurrence')
         occurences = composition_matrix.sum(0)
         occurences_descending = is_ascending(occurences[::-1])
         self.assertTrue(occurences_descending)
예제 #3
0
 def test_order_chunks_size_ascending(self):
     for _ in range(10):
         sets = make_random_sets()
         chunks, _ = _get_ordered_chunks_and_composition_array(sets, chunks_ordering='size',
                                                               reverse_chunks_order=False)
         chunk_sizes_ascending = is_ascending([len(chunk) for chunk in chunks])
         self.assertTrue(chunk_sizes_ascending)
예제 #4
0
 def test_order_sets_size_descending(self):
     for _ in range(1):
         sets = make_random_sets()
         chunks, composition_matrix = _get_ordered_chunks_and_composition_array(sets, sets_ordering='size')
         chunk_sizes = np.array([len(chunk) for chunk in chunks])
         set_sizes = composition_matrix.dot(chunk_sizes.reshape((-1, 1))).flatten()
         set_sizes_descending = is_ascending(set_sizes[::-1])
         self.assertTrue(set_sizes_descending)
예제 #5
0
 def test_order_sets_random(self):
     done = False
     while not done:
         sets = make_random_sets(min_sets_count=9)
         chunks, composition_matrix = get_chunks_and_composition_array(sets)
         if len(chunks) == 1:
             continue
         representations_set = set()
         for i in range(10):
             _, composition_matrix = _get_ordered_chunks_and_composition_array(sets, sets_ordering='random')
             representations_set.add(str(composition_matrix))
         self.assertGreater(len(representations_set), 1)
         done = True