Skip to content

Instantly share code, notes, and snippets.

@Gridflare
Gridflare / rollpad.py
Last active October 26, 2023 16:11
Numpy roll with padding
import numpy as np
def rollpad(array, rollx, rolly, mode='edge'):
"""Analogous to numpy.roll but using np.pad
for greater flexibility"""
if rollx > 0:
xpad = (rollx,0)
xtrim = slice(0,-rollx)
else: