I have two trival arrays with the same length, tmp_reds and tmp_blues:
npts = 4
tmp_reds = np.array(['red', 'red', 'red', 'red'])
tmp_blues = np.array(['blue', 'blue', 'blue', 'blue'])
I use np.repeat to create plurality:
red_occupations = [1, 0, 1, 2]
blue_occupations = [0, 2, 0, 1]
x = np.repeat(tmp_reds, red_occupations)
y = np.repeat(tmp_blues, blue_occupations)
print(x)
['red' 'red' 'red' 'red']
print(y)
['blue' 'blue' 'blue']
What I want is the following composite element x and y:
desired_array = np.array(['red', 'blue', 'blue', 'red', 'red', 'red', 'blue'])
So request_array is defined as follows:
(1) Multiplicity from the first red_occupations element is applied
(2) Multiplicity from the first blue_occupations element is applied
(3) Multiplicity from the second red_occupations element is applied
(4) Multiplicity from the second element blue_occupations is applied
...
(2 * npts-1) Many of the npts of the red_occupations element apply
(2 * npts) Multiplicity from the npts blue_occupations element is applied
, np.repeat. np.repeat , . - - , , - , np.repeat?
wish_array numpy, zipped for . npts ~ 1e7, .