Offsets inputs by offset >>> double = lambda x: x * 2 >>> f = offset_func(double, (10,)) >>> f(1) 22 >>> f(300) 620
(func, offset, *args)
| 5400 | |
| 5401 | |
| 5402 | def offset_func(func, offset, *args): |
| 5403 | """Offsets inputs by offset |
| 5404 | |
| 5405 | >>> double = lambda x: x * 2 |
| 5406 | >>> f = offset_func(double, (10,)) |
| 5407 | >>> f(1) |
| 5408 | 22 |
| 5409 | >>> f(300) |
| 5410 | 620 |
| 5411 | """ |
| 5412 | |
| 5413 | def _offset(*args): |
| 5414 | args2 = list(map(add, args, offset)) |
| 5415 | return func(*args2) |
| 5416 | |
| 5417 | with contextlib.suppress(Exception): |
| 5418 | _offset.__name__ = f"offset_{func.__name__}" |
| 5419 | |
| 5420 | return _offset |
| 5421 | |
| 5422 | |
| 5423 | def chunks_from_arrays(arrays): |
nothing calls this directly
no outgoing calls
no test coverage detected