Returns the proper backend for a list of input arrays Accepts None entries in the arguments, and ignores them Also raises TypeError if all arrays are not from the same backend
(*args)
| 210 | |
| 211 | |
| 212 | def get_backend(*args): |
| 213 | """Returns the proper backend for a list of input arrays |
| 214 | |
| 215 | Accepts None entries in the arguments, and ignores them |
| 216 | |
| 217 | Also raises TypeError if all arrays are not from the same backend |
| 218 | """ |
| 219 | args = [arg for arg in args if arg is not None] # exclude None entries |
| 220 | |
| 221 | # check that some arrays given |
| 222 | if not len(args) > 0: |
| 223 | raise ValueError(" The function takes at least one (non-None) parameter") |
| 224 | |
| 225 | for backend_impl in _BACKEND_IMPLEMENTATIONS: |
| 226 | if _check_args_backend(backend_impl, args): |
| 227 | return _get_backend_instance(backend_impl) |
| 228 | |
| 229 | raise ValueError("Unknown type of non implemented backend.") |
| 230 | |
| 231 | |
| 232 | def to_numpy(*args): |