Вы можете обернуть numpy.random.seed
в свою функцию, чтобы сделать ее воспроизводимой.Что-то вроде (в зависимости от вашего подхода):
# note: will not work properly if your two lists are different shapes:
def my_partition(list_in, n):
np.random.seed(1)
idx = np.random.shuffle(list_in)
return [list_in[i::n] for i in range(n)]
Или (немного другой подход, который должен работать)
def my_partition(list_in, n):
np.random.seed(1)
idx = np.random.choice(range(len(list_in)), len(list_in))
split = np.split(idx, n)
return [list_in[i] for i in split]