Skip to content

Commit dd2a32c

Browse files
committed
adding suggestions
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
1 parent be2a90c commit dd2a32c

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

docs/api-reference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@
2626
setdiff1d
2727
sinc
2828
union1d
29+
angle
2930
```

src/array_api_extra/_lib/_funcs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ def angle(z: Array, /, *, deg: bool = False, xp: ModuleType | None = None) -> Ar
838838
-------
839839
array
840840
The counterclockwise angle from the positive real axis on the complex
841-
plane in the range ``(-pi, pi]``, with dtype as float64.
841+
plane in the range ``(-pi, pi]``.
842842
843843
Examples
844844
--------

tests/test_funcs.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,23 +1918,28 @@ def test_basic(self, xp: ModuleType):
19181918
],
19191919
dtype=xp.float64,
19201920
)
1921-
xp_assert_close(angle(x), expected, rtol=0, atol=1e-11)
1922-
xp_assert_close(angle(x, deg=True), expected * 180 / xp.pi, rtol=0, atol=1e-11)
1921+
xp_assert_close(angle(x, xp=xp), expected, rtol=0, atol=1e-11)
1922+
xp_assert_close(
1923+
angle(x, deg=True, xp=xp),
1924+
expected * 180 / xp.pi,
1925+
rtol=0,
1926+
atol=1e-11,
1927+
)
19231928

19241929
def test_real(self, xp: ModuleType):
19251930
x = xp.asarray([0.0, -0.0, 1.0, -1.0])
19261931
expected = xp.asarray([0.0, xp.pi, 0.0, xp.pi], dtype=x.dtype)
1927-
xp_assert_close(angle(x), expected)
1932+
xp_assert_close(angle(x, xp=xp), expected)
19281933

19291934
def test_complex(self, xp: ModuleType):
19301935
a = xp.asarray([1 + 1j, 1 - 1j, -1 + 1j, -1 - 1j])
19311936
expected = xp.asarray([xp.pi / 4, -xp.pi / 4, 3 * xp.pi / 4, -3 * xp.pi / 4])
1932-
res = angle(a)
1937+
res = angle(a, xp=xp)
19331938
xp_assert_equal(res, expected)
19341939

19351940
def test_integral(self, xp: ModuleType):
19361941
x = xp.asarray([0, -1, 1], dtype=xp.int32)
1937-
actual = angle(x)
1942+
actual = angle(x, xp=xp)
19381943
expected = xp.asarray(
19391944
[0.0, xp.pi, 0.0], dtype=default_dtype(xp, device=get_device(x))
19401945
)
@@ -1945,7 +1950,7 @@ def test_2d(self, xp: ModuleType):
19451950
expected = xp.asarray(
19461951
[[xp.pi / 4, -xp.pi / 4], [3 * xp.pi / 4, -3 * xp.pi / 4]]
19471952
)
1948-
res = angle(a)
1953+
res = angle(a, xp=xp)
19491954
xp_assert_equal(res, expected)
19501955

19511956
@pytest.mark.skip_xp_backend(Backend.TORCH, reason="materialize 'meta' device")

0 commit comments

Comments
 (0)