Skip to content

Instantly share code, notes, and snippets.

@daguiam
Last active May 13, 2020 16:18
Show Gist options
  • Save daguiam/d71b2b94545e0b547b130579cd0bc2f5 to your computer and use it in GitHub Desktop.
Save daguiam/d71b2b94545e0b547b130579cd0bc2f5 to your computer and use it in GitHub Desktop.
def clip_remainder(x, clip):
if isinstance(clip, tuple):
print("is tuple")
assert len(clip) == 2, "Clip should be (min, max)"
clipmin,clipmax = clip
else:
clipmin = -clip
clipmax = clip
clipptp = np.ptp([clipmin, clipmax])
xaux = x
xaux = xaux-clipmin
xaux = np.remainder(xaux, clipptp)
xaux = xaux+clipmin
return xaux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment