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

Function test_fun_to_numpy

test/test_utils.py:736–751  ·  view source on GitHub ↗
(nx)

Source from the content-addressed store, hash-verified

734
735
736def test_fun_to_numpy(nx):
737 arr = np.arange(5)
738 arrb = nx.from_numpy(arr)
739
740 def fun(x): # backend function
741 return nx.sum(x)
742
743 fun_numpy = ot.utils.fun_to_numpy(fun, arrb, nx, warn=True)
744
745 res = nx.to_numpy(fun(arrb))
746 res_np = fun_numpy(arr)
747
748 np.testing.assert_allclose(res, res_np)
749
750 with pytest.raises(ValueError):
751 ot.utils.fun_to_numpy(fun, None, nx, warn=True)

Callers

nothing calls this directly

Calls 5

fun_numpyFunction · 0.85
from_numpyMethod · 0.80
to_numpyMethod · 0.80
funFunction · 0.70
arangeMethod · 0.45

Tested by

no test coverage detected