Last active
May 13, 2020 16:18
-
-
Save daguiam/d71b2b94545e0b547b130579cd0bc2f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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