Last active
April 25, 2019 00:35
-
-
Save moskytw/70d25b2d05049e5bf10e32e163add181 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python | |
from math import log | |
import funcy as fy | |
def f(x): | |
return x | |
def log_transform_func(base, f): | |
@fy.wraps(f) | |
def wrapped_f(*args, **kwargs): | |
return log(f(*args, **kwargs), base) | |
return wrapped_f | |
log_transform_deco = fy.autocurry(log_transform_func) | |
@log_transform_deco(10) | |
def g(x): | |
return x | |
if __name__ == '__main__': | |
assert log_transform_func(10, f)(100) == 2 | |
assert log_transform_deco(10)(f)(100) == 2 | |
assert g(100) == 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment