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

Function f

ot/lp/_network_simplex.py:509–542  ·  view source on GitHub ↗
(b)

Source from the content-addressed store, hash-verified

507 if log or return_matrix:
508
509 def f(b):
510 bsel = b != 0
511
512 G, cost, u, v, result_code = emd_c(a, b, M, numItermax, numThreads)
513
514 if center_dual:
515 u, v = center_ot_dual(u, v, a, b)
516
517 if np.any(~asel) or np.any(~bsel):
518 u, v = estimate_dual_null_weights(u, v, a, b, M)
519
520 result_code_string = check_result(result_code)
521 log = {}
522 if not nx.is_floating_point(type_as):
523 warnings.warn(
524 "Input histogram consists of integer. The transport plan will be "
525 "casted accordingly, possibly resulting in a loss of precision. "
526 "If this behaviour is unwanted, please make sure your input "
527 "histogram consists of floating point elements.",
528 stacklevel=2,
529 )
530 G = nx.from_numpy(G, type_as=type_as)
531 if return_matrix:
532 log["G"] = G
533 log["u"] = nx.from_numpy(u, type_as=type_as)
534 log["v"] = nx.from_numpy(v, type_as=type_as)
535 log["warning"] = result_code_string
536 log["result_code"] = result_code
537 cost = nx.set_gradients(
538 nx.from_numpy(cost, type_as=type_as),
539 (a0, b0, M0),
540 (log["u"] - nx.mean(log["u"]), log["v"] - nx.mean(log["v"]), G),
541 )
542 return [cost, log]
543 else:
544
545 def f(b):

Callers 1

emd2Function · 0.70

Calls 7

center_ot_dualFunction · 0.85
from_numpyMethod · 0.80
anyMethod · 0.45
is_floating_pointMethod · 0.45
set_gradientsMethod · 0.45
meanMethod · 0.45

Tested by

no test coverage detected