MCPcopy Create free account
hub / github.com/PythonOT/POT / get_backend

Function get_backend

ot/backend.py:212–229  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

210
211
212def 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
232def to_numpy(*args):

Callers 15

tensor_batchFunction · 0.90
loss_quadratic_batchFunction · 0.90
solve_gromov_batchFunction · 0.90
tensor_product_batchFunction · 0.90
transposeFunction · 0.90
detach_cost_tensorFunction · 0.90
entropy_batchFunction · 0.90
norm_batchFunction · 0.90
bregman_projection_batchFunction · 0.90

Calls 2

_check_args_backendFunction · 0.85
_get_backend_instanceFunction · 0.85

Tested by 5

test_get_backend_invalidFunction · 0.72
test_get_backendFunction · 0.72
test_get_backend_noneFunction · 0.72
verify_gluing_validityFunction · 0.72