Exemplo n.º 1
0
 def __shuffled(self):
     
     shuffel_corpus = OrderedDict()
     shuffe_keys = list(self.__corpus.keys())
     np_shuffle(shuffe_keys)
     for key in shuffe_keys:
         shuffel_corpus[key] = self.__corpus.get(key)
     self.__corpus = shuffel_corpus
Exemplo n.º 2
0
def randomize_matrix(data, savefig=None):
    size = len(data)
    rand_data = copy(data)
    for d in xrange(size):
        diag = zip(*[range(d, size), range(size - d)])
        rdiag = diag[:]
        np_shuffle(rdiag)
        for v in xrange(len(diag)):
            val = data[diag[v][0]][diag[v][1]]
            a, b = rdiag[v][0], rdiag[v][1]
            rand_data[b][a] = rand_data[a][b] = val
    if savefig:
        plt.subplot(211)
        plt.imshow(log2(data), interpolation='none')
        plt.subplot(212)
        plt.imshow(log2(rand_data), interpolation='none')
        plt.savefig(savefig, format='pdf')
        plt.close('all')
    return rand_data
Exemplo n.º 3
0
        def shuffle(array):
            np_shuffle(array)

            # Store a copy of the array for the assert
            mock_context['shuffled_array'] = array.copy()
Exemplo n.º 4
0
        def shuffle(array):
            np_shuffle(array)

            # Store a copy of the array for the assert
            mock_context['shuffled_array'] = array.copy()