Download scripts/lib/functools.py from AccelerationConsortium/temperature-sensor: direct link, hf CLI and curl.
- Browser
- Download file 586 Bytes
-
https://huggingface.co/spaces/AccelerationConsortium/temperature-sensor/resolve/main/scripts/lib/functools.py
- Command line
-
hf download hf://spaces/AccelerationConsortium/temperature-sensor/scripts/lib/functools.py
-
curl -L -o functools.py https://huggingface.co/spaces/AccelerationConsortium/temperature-sensor/resolve/main/scripts/lib/functools.py
586 Bytes
| def partial(func, *args, **kwargs): | |
| def _partial(*more_args, **more_kwargs): | |
| kw = kwargs.copy() | |
| kw.update(more_kwargs) | |
| func(*(args + more_args), **kw) | |
| return _partial | |
| def update_wrapper(wrapper, wrapped): | |
| # Dummy impl | |
| return wrapper | |
| def wraps(wrapped): | |
| # Dummy impl | |
| return lambda x: x | |
| def reduce(function, iterable, initializer=None): | |
| it = iter(iterable) | |
| if initializer is None: | |
| value = next(it) | |
| else: | |
| value = initializer | |
| for element in it: | |
| value = function(value, element) | |
| return value | |