Skip to content

Commit 81c5651

Browse files
committed
test correction + pre commit
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
1 parent 0ec328b commit 81c5651

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/array_api_extra/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
)
2020
from ._lib._at import at
2121
from ._lib._funcs import (
22+
angle,
2223
apply_where,
2324
broadcast_shapes,
2425
default_dtype,
2526
kron,
2627
nunique,
27-
angle,
2828
)
2929
from ._lib._lazy import lazy_apply
3030

@@ -33,6 +33,7 @@
3333
# pylint: disable=duplicate-code
3434
__all__ = [
3535
"__version__",
36+
"angle",
3637
"apply_where",
3738
"argpartition",
3839
"at",
@@ -55,5 +56,4 @@
5556
"setdiff1d",
5657
"sinc",
5758
"union1d",
58-
"angle",
5959
]

src/array_api_extra/_lib/_funcs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ def angle(z: Array, deg: bool = False, /, *, xp: ModuleType | None = None) -> Ar
835835
836836
Returns
837837
-------
838-
angle : ndarray or scalar
838+
ndarray or scalar
839839
The counterclockwise angle from the positive real axis on the complex
840840
plane in the range ``(-pi, pi]``, with dtype as float64.
841841
"""
@@ -850,4 +850,4 @@ def angle(z: Array, deg: bool = False, /, *, xp: ModuleType | None = None) -> Ar
850850
a = xp.atan2(zimage, zreal)
851851
if deg:
852852
a = a * 180 / xp.pi
853-
return a
853+
return a

tests/test_funcs.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from typing_extensions import override
1414

1515
from array_api_extra import (
16+
angle,
1617
apply_where,
1718
argpartition,
1819
at,
@@ -33,7 +34,6 @@
3334
setdiff1d,
3435
sinc,
3536
union1d,
36-
angle,
3737
)
3838
from array_api_extra import (
3939
searchsorted as xpx_searchsorted,
@@ -1883,10 +1883,11 @@ def test_device(self, xp: ModuleType, device: Device):
18831883
b = xp.asarray([2, -2, 0], device=device)
18841884
assert get_device(union1d(a, b)) == device
18851885

1886+
18861887
class TestAngle:
18871888
def test_simple(self, xp: ModuleType):
18881889
a = xp.asarray([1, 0])
1889-
expected = xp.asarray([0., 0.])
1890+
expected = xp.asarray([0.0, 0.0], dtype=xp.float64)
18901891
res = angle(a)
18911892
xp_assert_equal(res, expected)
18921893

@@ -1898,11 +1899,13 @@ def test_complex(self, xp: ModuleType):
18981899

18991900
def test_2d(self, xp: ModuleType):
19001901
a = xp.asarray([[1 + 1j, 1 - 1j], [-1 + 1j, -1 - 1j]])
1901-
expected = xp.asarray([[np.pi / 4, -np.pi / 4], [3 * np.pi / 4, -3 * np.pi / 4]])
1902+
expected = xp.asarray(
1903+
[[np.pi / 4, -np.pi / 4], [3 * np.pi / 4, -3 * np.pi / 4]]
1904+
)
19021905
res = angle(a)
19031906
xp_assert_equal(res, expected)
19041907

19051908
@pytest.mark.skip_xp_backend(Backend.TORCH, reason="materialize 'meta' device")
19061909
def test_device(self, xp: ModuleType, device: Device):
19071910
a = xp.asarray([1 + 1j], device=device)
1908-
assert get_device(angle(a)) == device
1911+
assert get_device(angle(a)) == device

0 commit comments

Comments
 (0)