python - Multiple Numpy random shuffles does not add up -


I am trying to generate an array of neighbors, each neighbor is different from previous neighbors in the previous random shuffle, Either a line or column shuffle should be prepared only when a certain line or column is greater than K1, and if so, then a neighbor should be reversed by this row or column. Shuffle should be added, which means if the first row is rotated and then one column; Two neighbors should be built, with a resizing line and a line and a column.

However, it seems that the array is only two times, one for the column loop and one for the other loop, and the shuffle is not added.

In this example, column index 1 and 2 should be shuffled, and row index 3 and 4. Here is an example, showing the population generated. [[0 1 1] [0 0 0 0] [0 0] [0 1 1 0] [1 1 1 0]] [0 0 1 1] [0 0 0 0] [0 0 1 0] [0 1 0 0] [1 1 1]] [[0 1 1] [0 0 0 0] [0 0 1 0 1] [0 1 0 0] [1 1 0]] [[0 1 0] [0 0 1 0] [0 1 1 0 0]

Here is the code:

  k = 2 tmp = np.array ([, 0, 0, 1, 1], [0], 0, 1, 0, 0 ], [1, 0, 0, 0], [0, 1, 1, 1, 0], [1, 1, 1, 0, 1]]) board = NP. CPP (TMP) column = NPSUM (Board, axis = 0) - column = lane (column) row = np. (Board, axis = 1) - lines = lane (line) neighbors = [] in the range (column): if the column [i] & gt; 0: np.random.shuffle (board [:, i]) neighbors Expansion (NP copy): In the range (rows): If the line [i] & gt; 0: np.random.shuffle (board [i,:]) .append (np.copy (board)) for neighbors in neighboring print tmp print column print line I: print i   

Your code works :) < P> It is just that sometimes a row or column is rotated, but it remains in the same configuration. Compare to:

  ar = np.array ([0, 1]) for _ category (10): print ar np.random.shuffle (ar)   

Also, it is not impossible that the elements of a row or column have actually been altered, but you will end up with people in the same place and zero (because only limited limited permutations the number is).

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -