Skip to content

Commit fb0a474

Browse files
committed
Run generate_stubs on the latest spec
1 parent b080ded commit fb0a474

File tree

6 files changed

+276
-12
lines changed

6 files changed

+276
-12
lines changed

array_api_tests/function_stubs/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141

4242
__all__ += ['argmax', 'argmin', 'nonzero', 'where']
4343

44-
from .set_functions import unique_all, unique_inverse, unique_values
44+
from .set_functions import unique_all, unique_counts, unique_inverse, unique_values
4545

46-
__all__ += ['unique_all', 'unique_inverse', 'unique_values']
46+
__all__ += ['unique_all', 'unique_counts', 'unique_inverse', 'unique_values']
4747

4848
from .sorting_functions import argsort, sort
4949

array_api_tests/function_stubs/set_functions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515
def unique_all(x: array, /) -> Tuple[array, array, array, array]:
1616
pass
1717

18+
def unique_counts(x: array, /) -> Tuple[array, array]:
19+
pass
20+
1821
def unique_inverse(x: array, /) -> Tuple[array, array]:
1922
pass
2023

2124
def unique_values(x: array, /) -> array:
2225
pass
2326

24-
__all__ = ['unique_all', 'unique_inverse', 'unique_values']
27+
__all__ = ['unique_all', 'unique_counts', 'unique_inverse', 'unique_values']

array_api_tests/special_cases/test_ceil.py

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
not modify it directly.
88
"""
99

10-
from ..array_helpers import assert_exactly_equal, isintegral
10+
from ..array_helpers import NaN, assert_exactly_equal, exactly_equal, infinity, isintegral, zero
1111
from ..hypothesis_helpers import numeric_arrays
1212
from .._array_module import ceil
1313

1414
from hypothesis import given
1515

1616

1717
@given(numeric_arrays)
18-
def test_ceil_special_cases_one_arg_equal(arg1):
18+
def test_ceil_special_cases_one_arg_equal_1(arg1):
1919
"""
2020
Special case test for `ceil(x, /)`:
2121
@@ -25,3 +25,68 @@ def test_ceil_special_cases_one_arg_equal(arg1):
2525
res = ceil(arg1)
2626
mask = isintegral(arg1)
2727
assert_exactly_equal(res[mask], (arg1)[mask])
28+
29+
30+
@given(numeric_arrays)
31+
def test_ceil_special_cases_one_arg_equal_2(arg1):
32+
"""
33+
Special case test for `ceil(x, /)`:
34+
35+
- If `x_i` is `+infinity`, the result is `+infinity`.
36+
37+
"""
38+
res = ceil(arg1)
39+
mask = exactly_equal(arg1, infinity(arg1.shape, arg1.dtype))
40+
assert_exactly_equal(res[mask], (infinity(arg1.shape, arg1.dtype))[mask])
41+
42+
43+
@given(numeric_arrays)
44+
def test_ceil_special_cases_one_arg_equal_3(arg1):
45+
"""
46+
Special case test for `ceil(x, /)`:
47+
48+
- If `x_i` is `-infinity`, the result is `-infinity`.
49+
50+
"""
51+
res = ceil(arg1)
52+
mask = exactly_equal(arg1, -infinity(arg1.shape, arg1.dtype))
53+
assert_exactly_equal(res[mask], (-infinity(arg1.shape, arg1.dtype))[mask])
54+
55+
56+
@given(numeric_arrays)
57+
def test_ceil_special_cases_one_arg_equal_4(arg1):
58+
"""
59+
Special case test for `ceil(x, /)`:
60+
61+
- If `x_i` is `+0`, the result is `+0`.
62+
63+
"""
64+
res = ceil(arg1)
65+
mask = exactly_equal(arg1, zero(arg1.shape, arg1.dtype))
66+
assert_exactly_equal(res[mask], (zero(arg1.shape, arg1.dtype))[mask])
67+
68+
69+
@given(numeric_arrays)
70+
def test_ceil_special_cases_one_arg_equal_5(arg1):
71+
"""
72+
Special case test for `ceil(x, /)`:
73+
74+
- If `x_i` is `-0`, the result is `-0`.
75+
76+
"""
77+
res = ceil(arg1)
78+
mask = exactly_equal(arg1, -zero(arg1.shape, arg1.dtype))
79+
assert_exactly_equal(res[mask], (-zero(arg1.shape, arg1.dtype))[mask])
80+
81+
82+
@given(numeric_arrays)
83+
def test_ceil_special_cases_one_arg_equal_6(arg1):
84+
"""
85+
Special case test for `ceil(x, /)`:
86+
87+
- If `x_i` is `NaN`, the result is `NaN`.
88+
89+
"""
90+
res = ceil(arg1)
91+
mask = exactly_equal(arg1, NaN(arg1.shape, arg1.dtype))
92+
assert_exactly_equal(res[mask], (NaN(arg1.shape, arg1.dtype))[mask])

array_api_tests/special_cases/test_floor.py

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
not modify it directly.
88
"""
99

10-
from ..array_helpers import assert_exactly_equal, isintegral
10+
from ..array_helpers import NaN, assert_exactly_equal, exactly_equal, infinity, isintegral, zero
1111
from ..hypothesis_helpers import numeric_arrays
1212
from .._array_module import floor
1313

1414
from hypothesis import given
1515

1616

1717
@given(numeric_arrays)
18-
def test_floor_special_cases_one_arg_equal(arg1):
18+
def test_floor_special_cases_one_arg_equal_1(arg1):
1919
"""
2020
Special case test for `floor(x, /)`:
2121
@@ -25,3 +25,68 @@ def test_floor_special_cases_one_arg_equal(arg1):
2525
res = floor(arg1)
2626
mask = isintegral(arg1)
2727
assert_exactly_equal(res[mask], (arg1)[mask])
28+
29+
30+
@given(numeric_arrays)
31+
def test_floor_special_cases_one_arg_equal_2(arg1):
32+
"""
33+
Special case test for `floor(x, /)`:
34+
35+
- If `x_i` is `+infinity`, the result is `+infinity`.
36+
37+
"""
38+
res = floor(arg1)
39+
mask = exactly_equal(arg1, infinity(arg1.shape, arg1.dtype))
40+
assert_exactly_equal(res[mask], (infinity(arg1.shape, arg1.dtype))[mask])
41+
42+
43+
@given(numeric_arrays)
44+
def test_floor_special_cases_one_arg_equal_3(arg1):
45+
"""
46+
Special case test for `floor(x, /)`:
47+
48+
- If `x_i` is `-infinity`, the result is `-infinity`.
49+
50+
"""
51+
res = floor(arg1)
52+
mask = exactly_equal(arg1, -infinity(arg1.shape, arg1.dtype))
53+
assert_exactly_equal(res[mask], (-infinity(arg1.shape, arg1.dtype))[mask])
54+
55+
56+
@given(numeric_arrays)
57+
def test_floor_special_cases_one_arg_equal_4(arg1):
58+
"""
59+
Special case test for `floor(x, /)`:
60+
61+
- If `x_i` is `+0`, the result is `+0`.
62+
63+
"""
64+
res = floor(arg1)
65+
mask = exactly_equal(arg1, zero(arg1.shape, arg1.dtype))
66+
assert_exactly_equal(res[mask], (zero(arg1.shape, arg1.dtype))[mask])
67+
68+
69+
@given(numeric_arrays)
70+
def test_floor_special_cases_one_arg_equal_5(arg1):
71+
"""
72+
Special case test for `floor(x, /)`:
73+
74+
- If `x_i` is `-0`, the result is `-0`.
75+
76+
"""
77+
res = floor(arg1)
78+
mask = exactly_equal(arg1, -zero(arg1.shape, arg1.dtype))
79+
assert_exactly_equal(res[mask], (-zero(arg1.shape, arg1.dtype))[mask])
80+
81+
82+
@given(numeric_arrays)
83+
def test_floor_special_cases_one_arg_equal_6(arg1):
84+
"""
85+
Special case test for `floor(x, /)`:
86+
87+
- If `x_i` is `NaN`, the result is `NaN`.
88+
89+
"""
90+
res = floor(arg1)
91+
mask = exactly_equal(arg1, NaN(arg1.shape, arg1.dtype))
92+
assert_exactly_equal(res[mask], (NaN(arg1.shape, arg1.dtype))[mask])

array_api_tests/special_cases/test_round.py

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
not modify it directly.
88
"""
99

10-
from ..array_helpers import (assert_exactly_equal, assert_iseven, assert_positive, ceil, equal,
11-
floor, isintegral, logical_and, not_equal, one, subtract)
10+
from ..array_helpers import (NaN, assert_exactly_equal, assert_iseven, assert_positive, ceil, equal,
11+
exactly_equal, floor, infinity, isintegral, logical_and, not_equal,
12+
one, subtract, zero)
1213
from ..hypothesis_helpers import numeric_arrays
1314
from .._array_module import round
1415

1516
from hypothesis import given
1617

1718

1819
@given(numeric_arrays)
19-
def test_round_special_cases_one_arg_equal(arg1):
20+
def test_round_special_cases_one_arg_equal_1(arg1):
2021
"""
2122
Special case test for `round(x, /)`:
2223
@@ -28,6 +29,71 @@ def test_round_special_cases_one_arg_equal(arg1):
2829
assert_exactly_equal(res[mask], (arg1)[mask])
2930

3031

32+
@given(numeric_arrays)
33+
def test_round_special_cases_one_arg_equal_2(arg1):
34+
"""
35+
Special case test for `round(x, /)`:
36+
37+
- If `x_i` is `+infinity`, the result is `+infinity`.
38+
39+
"""
40+
res = round(arg1)
41+
mask = exactly_equal(arg1, infinity(arg1.shape, arg1.dtype))
42+
assert_exactly_equal(res[mask], (infinity(arg1.shape, arg1.dtype))[mask])
43+
44+
45+
@given(numeric_arrays)
46+
def test_round_special_cases_one_arg_equal_3(arg1):
47+
"""
48+
Special case test for `round(x, /)`:
49+
50+
- If `x_i` is `-infinity`, the result is `-infinity`.
51+
52+
"""
53+
res = round(arg1)
54+
mask = exactly_equal(arg1, -infinity(arg1.shape, arg1.dtype))
55+
assert_exactly_equal(res[mask], (-infinity(arg1.shape, arg1.dtype))[mask])
56+
57+
58+
@given(numeric_arrays)
59+
def test_round_special_cases_one_arg_equal_4(arg1):
60+
"""
61+
Special case test for `round(x, /)`:
62+
63+
- If `x_i` is `+0`, the result is `+0`.
64+
65+
"""
66+
res = round(arg1)
67+
mask = exactly_equal(arg1, zero(arg1.shape, arg1.dtype))
68+
assert_exactly_equal(res[mask], (zero(arg1.shape, arg1.dtype))[mask])
69+
70+
71+
@given(numeric_arrays)
72+
def test_round_special_cases_one_arg_equal_5(arg1):
73+
"""
74+
Special case test for `round(x, /)`:
75+
76+
- If `x_i` is `-0`, the result is `-0`.
77+
78+
"""
79+
res = round(arg1)
80+
mask = exactly_equal(arg1, -zero(arg1.shape, arg1.dtype))
81+
assert_exactly_equal(res[mask], (-zero(arg1.shape, arg1.dtype))[mask])
82+
83+
84+
@given(numeric_arrays)
85+
def test_round_special_cases_one_arg_equal_6(arg1):
86+
"""
87+
Special case test for `round(x, /)`:
88+
89+
- If `x_i` is `NaN`, the result is `NaN`.
90+
91+
"""
92+
res = round(arg1)
93+
mask = exactly_equal(arg1, NaN(arg1.shape, arg1.dtype))
94+
assert_exactly_equal(res[mask], (NaN(arg1.shape, arg1.dtype))[mask])
95+
96+
3197
@given(numeric_arrays)
3298
def test_round_special_cases_one_arg_two_integers_equally_close(arg1):
3399
"""

array_api_tests/special_cases/test_trunc.py

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
not modify it directly.
88
"""
99

10-
from ..array_helpers import assert_exactly_equal, isintegral
10+
from ..array_helpers import NaN, assert_exactly_equal, exactly_equal, infinity, isintegral, zero
1111
from ..hypothesis_helpers import numeric_arrays
1212
from .._array_module import trunc
1313

1414
from hypothesis import given
1515

1616

1717
@given(numeric_arrays)
18-
def test_trunc_special_cases_one_arg_equal(arg1):
18+
def test_trunc_special_cases_one_arg_equal_1(arg1):
1919
"""
2020
Special case test for `trunc(x, /)`:
2121
@@ -25,3 +25,68 @@ def test_trunc_special_cases_one_arg_equal(arg1):
2525
res = trunc(arg1)
2626
mask = isintegral(arg1)
2727
assert_exactly_equal(res[mask], (arg1)[mask])
28+
29+
30+
@given(numeric_arrays)
31+
def test_trunc_special_cases_one_arg_equal_2(arg1):
32+
"""
33+
Special case test for `trunc(x, /)`:
34+
35+
- If `x_i` is `+infinity`, the result is `+infinity`.
36+
37+
"""
38+
res = trunc(arg1)
39+
mask = exactly_equal(arg1, infinity(arg1.shape, arg1.dtype))
40+
assert_exactly_equal(res[mask], (infinity(arg1.shape, arg1.dtype))[mask])
41+
42+
43+
@given(numeric_arrays)
44+
def test_trunc_special_cases_one_arg_equal_3(arg1):
45+
"""
46+
Special case test for `trunc(x, /)`:
47+
48+
- If `x_i` is `-infinity`, the result is `-infinity`.
49+
50+
"""
51+
res = trunc(arg1)
52+
mask = exactly_equal(arg1, -infinity(arg1.shape, arg1.dtype))
53+
assert_exactly_equal(res[mask], (-infinity(arg1.shape, arg1.dtype))[mask])
54+
55+
56+
@given(numeric_arrays)
57+
def test_trunc_special_cases_one_arg_equal_4(arg1):
58+
"""
59+
Special case test for `trunc(x, /)`:
60+
61+
- If `x_i` is `+0`, the result is `+0`.
62+
63+
"""
64+
res = trunc(arg1)
65+
mask = exactly_equal(arg1, zero(arg1.shape, arg1.dtype))
66+
assert_exactly_equal(res[mask], (zero(arg1.shape, arg1.dtype))[mask])
67+
68+
69+
@given(numeric_arrays)
70+
def test_trunc_special_cases_one_arg_equal_5(arg1):
71+
"""
72+
Special case test for `trunc(x, /)`:
73+
74+
- If `x_i` is `-0`, the result is `-0`.
75+
76+
"""
77+
res = trunc(arg1)
78+
mask = exactly_equal(arg1, -zero(arg1.shape, arg1.dtype))
79+
assert_exactly_equal(res[mask], (-zero(arg1.shape, arg1.dtype))[mask])
80+
81+
82+
@given(numeric_arrays)
83+
def test_trunc_special_cases_one_arg_equal_6(arg1):
84+
"""
85+
Special case test for `trunc(x, /)`:
86+
87+
- If `x_i` is `NaN`, the result is `NaN`.
88+
89+
"""
90+
res = trunc(arg1)
91+
mask = exactly_equal(arg1, NaN(arg1.shape, arg1.dtype))
92+
assert_exactly_equal(res[mask], (NaN(arg1.shape, arg1.dtype))[mask])

0 commit comments

Comments
 (0)