In [1]:
%matplotlib inline
import numpy as np
from matplotlib import pyplot as plt
plt.style.use('bmh')

In [54]:
# function to reallocate active particles to the front of all local arrays
# active_n = "number of active particles after sending, before receiving. aka. particles that stays in its own rank"
def move_active_to_front(particle_local, particle_x_local, particle_active_local, active_n):
    particle_local[:active_n] = particle_local[particle_active_local]
    particle_x_local[:active_n] = particle_x_local[particle_active_local]
    # set the corresponding first particles to active, the rest to false
    particle_active_local[:active_n] = True
    particle_active_local[active_n:] = False

In [81]:
l = np.arange(6)
a = np.zeros(6, dtype = bool)
a[:] = [True, False, True, True, False, False]
a_n = 3
r = np.arange(6, 9)
r_n = 3

In [85]:
l.resize(7, refcheck=False)
l


Out[85]:
array([0, 1, 2, 3, 4, 5, 0])

In [86]:
a.resize(7, refcheck=False)
a


Out[86]:
array([ True, False,  True,  True, False, False, False], dtype=bool)

In [87]:
l[:0] = l[a]


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-87-719ad9ecba47> in <module>()
----> 1 l[:0] = l[a]

ValueError: could not broadcast input array from shape (3) into shape (0)

In [3]:
a = np.array([1,2,3,4,5,6])
a


Out[3]:
array([1, 2, 3, 4, 5, 6])

In [5]:
b = a.reshape(2,3)
b


Out[5]:
array([[1, 2, 3],
       [4, 5, 6]])

In [7]:
b[0,0] = 5
a


Out[7]:
array([5, 2, 3, 4, 5, 6])

In [16]:
h = []

In [17]:
if h:
    print('y')

In [ ]: