def stack_or_concat(list_of_arays): func = np.concatenate if list_of_arays[0].ndim == 1 else np.vstack return func(list_of_arays)