|
9 | 9 | import pytest |
10 | 10 | from numpy.testing import assert_allclose, assert_array_equal, assert_equal |
11 | 11 |
|
12 | | -from array_api_extra import atleast_nd, cov, expand_dims, kron |
| 12 | +from array_api_extra import atleast_nd, cov, expand_dims, kron, sinc |
13 | 13 |
|
14 | 14 | if TYPE_CHECKING: |
15 | 15 | Array = Any # To be changed to a Protocol later (see array-api#589) |
@@ -224,3 +224,16 @@ def test_positive_negative_repeated(self): |
224 | 224 | a = xp.empty((2, 3, 4, 5)) |
225 | 225 | with pytest.raises(ValueError, match="Duplicate dimensions"): |
226 | 226 | expand_dims(a, axis=(3, -3), xp=xp) |
| 227 | + |
| 228 | + |
| 229 | +class TestSinc: |
| 230 | + def test_simple(self): |
| 231 | + assert_array_equal(sinc(xp.asarray(0.0), xp=xp), xp.asarray(1.0)) |
| 232 | + w = sinc(xp.linspace(-1, 1, 100), xp=xp) |
| 233 | + # check symmetry |
| 234 | + assert_allclose(w, xp.flip(w, axis=0)) |
| 235 | + |
| 236 | + @pytest.mark.parametrize("x", [0, 1 + 3j]) |
| 237 | + def test_dtype(self, x): |
| 238 | + with pytest.raises(ValueError, match="real floating data type"): |
| 239 | + sinc(xp.asarray(x), xp=xp) |
0 commit comments