if weight is None:
weight = np.ones_like(im)
wt_pad = np.pad(weight, [pad, pad], constant_values=0.)
wt_pad[wt_pad == 0] = 1e-20
Eddie: You're duplicating my existing code, but I can't figure out for the life of me why I did this. Let's keep this for this commit, but can you file an issue to check removing this after we merge this commit?