(implementation)
| 140 | |
| 141 | """ |
| 142 | def decorator(implementation): |
| 143 | if verify: |
| 144 | if dispatcher is not None: |
| 145 | verify_matching_signatures(implementation, dispatcher) |
| 146 | else: |
| 147 | # Using __code__ directly similar to verify_matching_signature |
| 148 | co = implementation.__code__ |
| 149 | last_arg = co.co_argcount + co.co_kwonlyargcount - 1 |
| 150 | last_arg = co.co_varnames[last_arg] |
| 151 | if last_arg != "like" or co.co_kwonlyargcount == 0: |
| 152 | raise RuntimeError( |
| 153 | "__array_function__ expects `like=` to be the last " |
| 154 | "argument and a keyword-only argument. " |
| 155 | f"{implementation} does not seem to comply.") |
| 156 | |
| 157 | if docs_from_dispatcher: |
| 158 | add_docstring(implementation, dispatcher.__doc__) |
| 159 | |
| 160 | public_api = _ArrayFunctionDispatcher(dispatcher, implementation) |
| 161 | public_api = functools.wraps(implementation)(public_api) |
| 162 | |
| 163 | if module is not None: |
| 164 | public_api.__module__ = module |
| 165 | |
| 166 | ARRAY_FUNCTIONS.add(public_api) |
| 167 | |
| 168 | return public_api |
| 169 | |
| 170 | return decorator |
| 171 |
nothing calls this directly
no test coverage detected