"""Miscellaneous tools, boilerplate, and shortcuts"""fromfunctoolsimportpartialdefidentity(obj):returnobjclassCallableAsMethod(object):"""mixin for callables to be callable as methods when bound to a class"""def__get__(self,obj,objtype=None):returnselfifobjisNoneelsepartial(self,obj)
[docs]classcompose(CallableAsMethod):"""compose a function from a chain of functions Parameters ---------- *funcs callables to compose Note ---- * if given no functions, acts as an identity function """