def shear3(a, strength=1, shift_axis=0, increase_axis=1):
    if shift_axis > increase_axis:
        shift_axis -= 1
res = numpy.empty_like(a)
index = numpy.index_exp[:] * increase_axis
roll = numpy.roll
for i in range(0, a.shape[increase_axis]):
    index_i = index + (i,)
res[index_i] = roll(a[index_i], -i * strength, shift_axis)
return res
Shear a numpy array