Python: Justifying NumPy array
Here’s a vectorized approach inspired by this other post and generalized to cover non-zeros for all four directions – def justify(a, invalid_val=0, axis=1, side=”left”): “”” Justifies a 2D array Parameters ———- A : ndarray Input array to be justified axis : int Axis along which justification is to be made side : str Direction of … Read more