(nx)
| 734 | |
| 735 | |
| 736 | def 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) |
nothing calls this directly
no test coverage detected