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

Function phi

ot/optim.py:100–117  ·  view source on GitHub ↗
(alpha1)

Source from the content-addressed store, hash-verified

98 fc = [0]
99
100 def phi(alpha1):
101 # it's necessary to check boundary condition here for the coefficient
102 # as the callback could be evaluated for negative value of alpha by
103 # `scalar_search_armijo` function here:
104 #
105 # https://github.com/scipy/scipy/blob/11509c4a98edded6c59423ac44ca1b7f28fba1fd/scipy/optimize/linesearch.py#L686
106 #
107 # see more details https://github.com/PythonOT/POT/issues/502
108 alpha1 = np.clip(alpha1, alpha_min, alpha_max)
109 # The callable function operates on nx backend
110 fc[0] += 1
111 alpha10 = nx.from_numpy(alpha1)
112 fval = f(xk0 + alpha10 * pk0, *args)
113 if isinstance(fval, float):
114 # prevent bug from nx.to_numpy that can look for .cpu or .gpu
115 return fval
116 else:
117 return nx.to_numpy(fval)
118
119 if old_fval is None:
120 phi0 = phi(0.0)

Callers 1

line_search_armijoFunction · 0.85

Calls 4

from_numpyMethod · 0.80
to_numpyMethod · 0.80
fFunction · 0.70
clipMethod · 0.45

Tested by

no test coverage detected