|
28 | 28 | ellipkinc as scipy_ellipkinc, |
29 | 29 | ellipe as scipy_ellipe, |
30 | 30 | ellipeinc as scipy_ellipeinc, |
| 31 | + fresnel as scipy_fresnel, |
31 | 32 | betainc as scipy_betainc, |
32 | 33 | ) |
33 | 34 |
|
34 | 35 | from ....lib.version import parse as parse_version |
35 | | -from ....core import tile |
| 36 | +from ....core import tile, ExecutableTuple |
36 | 37 | from ... import tensor |
37 | 38 | from ..err_fresnel import ( |
38 | 39 | erf, |
|
47 | 48 | TensorErfinv, |
48 | 49 | erfcinv, |
49 | 50 | TensorErfcinv, |
| 51 | + fresnel, |
| 52 | + TensorFresnel, |
50 | 53 | ) |
51 | 54 | from ..gamma_funcs import ( |
52 | 55 | gammaln, |
@@ -276,6 +279,48 @@ def test_erfcinv(): |
276 | 279 | assert c.shape == c.inputs[0].shape |
277 | 280 |
|
278 | 281 |
|
| 282 | +def test_fresnel(): |
| 283 | + raw = np.random.rand(10, 8, 5) |
| 284 | + t = tensor(raw, chunk_size=3) |
| 285 | + |
| 286 | + r = fresnel(t) |
| 287 | + expect = scipy_fresnel(raw) |
| 288 | + |
| 289 | + assert isinstance(r, ExecutableTuple) |
| 290 | + assert len(r) == 2 |
| 291 | + |
| 292 | + for i in range(len(r)): |
| 293 | + assert r[i].shape == expect[i].shape |
| 294 | + assert r[i].dtype == expect[i].dtype |
| 295 | + assert isinstance(r[i].op, TensorFresnel) |
| 296 | + |
| 297 | + non_tuple_out = tensor(raw, chunk_size=3) |
| 298 | + with pytest.raises(TypeError): |
| 299 | + r = fresnel(t, non_tuple_out) |
| 300 | + |
| 301 | + mismatch_size_tuple = ExecutableTuple([t]) |
| 302 | + with pytest.raises(TypeError): |
| 303 | + r = fresnel(t, mismatch_size_tuple) |
| 304 | + |
| 305 | + out = ExecutableTuple([t, t]) |
| 306 | + r_out = fresnel(t, out=out) |
| 307 | + |
| 308 | + assert isinstance(out, ExecutableTuple) |
| 309 | + assert isinstance(r_out, ExecutableTuple) |
| 310 | + |
| 311 | + assert len(out) == 2 |
| 312 | + assert len(r_out) == 2 |
| 313 | + |
| 314 | + for r_output, expected_output, out_output in zip(r, expect, out): |
| 315 | + assert r_output.shape == expected_output.shape |
| 316 | + assert r_output.dtype == expected_output.dtype |
| 317 | + assert isinstance(r_output.op, TensorFresnel) |
| 318 | + |
| 319 | + assert out_output.shape == expected_output.shape |
| 320 | + assert out_output.dtype == expected_output.dtype |
| 321 | + assert isinstance(out_output.op, TensorFresnel) |
| 322 | + |
| 323 | + |
279 | 324 | def test_beta_inc(): |
280 | 325 | raw1 = np.random.rand(4, 3, 2) |
281 | 326 | raw2 = np.random.rand(4, 3, 2) |
|
0 commit comments