Skip to content

Manipulation and statistical tests, smoke all untested functions #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
5a1a19f
Move manipulation tests to their own file
honno Nov 9, 2021
6dd7f3d
Minor `test_concat` improvements
honno Nov 9, 2021
e5bb974
Smoke all manipulation methods
honno Nov 9, 2021
41a0292
Smoke statistical functions
honno Nov 9, 2021
97997ee
Smoke searching functions
honno Nov 9, 2021
3efff6c
Smoke remaining functions
honno Nov 10, 2021
08b2391
Test `expand_dims()`
honno Nov 10, 2021
40a74bf
Test `flip()` when `axis=None`
honno Nov 10, 2021
d05a612
Test `permute_dims()`
honno Nov 10, 2021
a9f9237
Test `reshape()`
honno Nov 10, 2021
3ac57ef
Test `roll()`
honno Nov 10, 2021
258b75e
Test `squeeze()`
honno Nov 10, 2021
1bdf6e4
Refactor assertions using ndindex
honno Nov 10, 2021
f1cc3ea
Fix `test_roll`
honno Nov 11, 2021
36679c4
Test `concat()`
honno Nov 11, 2021
a8fb70d
Test `stack()`
honno Nov 11, 2021
cf76888
Manipulation tests clean up
honno Nov 11, 2021
30a0721
Improve `min()`/`max()` tests
honno Nov 11, 2021
50a63b2
Test `mean()`
honno Nov 12, 2021
1ff7271
Test `prod()`
honno Nov 12, 2021
f426f88
Refactor axes strategies for stat functions
honno Nov 12, 2021
1238e75
Test `std()`
honno Nov 12, 2021
d1eece1
Test axes results
honno Nov 15, 2021
687e40a
Test `var()` and `sum()`
honno Nov 15, 2021
d38eee2
Generate all valid dtypes in `test_prod` and `test_sum`
honno Nov 15, 2021
704e47b
Cover axis in `test_concat`
honno Nov 16, 2021
40167c3
Cover axis in `test_flip`
honno Nov 16, 2021
2decdf0
Cover elements in `test_permute_dims`
honno Nov 16, 2021
80c4e31
Fix `test_concat` axes iteration
honno Dec 6, 2021
767bd3f
Cover all shift/axes scenarios in `test_roll`
honno Dec 6, 2021
aa7aaa0
Cover all axis scenarios in `test_stack`
honno Dec 7, 2021
b32fff0
Make float assertions more lenient in statistical tests
honno Dec 7, 2021
5978fda
Update sum and prod tests to use new default uint
honno Dec 7, 2021
9f3a83e
Sort statistical tests by spec order
honno Dec 8, 2021
09aa26b
Check error raising in `test_squeeze`, use negative axes
honno Dec 8, 2021
18709f6
Cover invalid axis in `test_expand_dims`
honno Dec 8, 2021
2ad6ddc
Try to ignore overflow scenarios in `prod` and `sum` tests
honno Dec 8, 2021
6e4564b
Docstrings for axes helpers
honno Dec 8, 2021
0326aa3
Remove redundant calls to `dh.get_scalar_type()`
honno Dec 8, 2021
cd8f117
Fix `test_manipulation_functions.assert_equals`
honno Dec 10, 2021
af285de
Skip `test_roll` as its wrong
honno Dec 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
421 changes: 212 additions & 209 deletions array_api_tests/dtype_helpers.py

Large diffs are not rendered by default.

47 changes: 46 additions & 1 deletion array_api_tests/meta/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import pytest

from ..test_signatures import extension_module
from .. import array_helpers as ah
from ..test_creation_functions import frange
from ..test_manipulation_functions import axis_ndindex
from ..test_signatures import extension_module
from ..test_statistical_functions import axes_ndindex


def test_extension_module_is_extension():
Expand All @@ -24,3 +27,45 @@ def test_extension_func_is_not_extension():
def test_frange(r, size, elements):
assert len(r) == size
assert list(r) == elements


@pytest.mark.parametrize(
"shape, expected",
[((), [()])],
)
def test_ndindex(shape, expected):
assert list(ah.ndindex(shape)) == expected


@pytest.mark.parametrize(
"shape, axis, expected",
[
((1,), 0, [(slice(None, None),)]),
((1, 2), 0, [(slice(None, None), slice(None, None))]),
(
(2, 4),
1,
[(0, slice(None, None)), (1, slice(None, None))],
),
],
)
def test_axis_ndindex(shape, axis, expected):
assert list(axis_ndindex(shape, axis)) == expected


@pytest.mark.parametrize(
"shape, axes, expected",
[
((), (), [((),)]),
(
(2, 2),
(0,),
[
((0, 0), (1, 0)),
((0, 1), (1, 1)),
],
),
],
)
def test_axes_ndindex(shape, axes, expected):
assert list(axes_ndindex(shape, axes)) == expected
8 changes: 4 additions & 4 deletions array_api_tests/pytest_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ def fmt_kw(kw: Dict[str, Any]) -> str:

def assert_dtype(
func_name: str,
in_dtypes: Tuple[DataType, ...],
in_dtypes: Union[DataType, Tuple[DataType, ...]],
out_dtype: DataType,
expected: Optional[DataType] = None,
*,
repr_name: str = "out.dtype",
):
if not isinstance(in_dtypes, tuple):
in_dtypes = (in_dtypes,)
f_in_dtypes = dh.fmt_types(in_dtypes)
f_out_dtype = dh.dtype_to_name[out_dtype]
if expected is None:
Expand Down Expand Up @@ -149,9 +151,7 @@ def assert_result_shape(
f_sig = f" {f_in_shapes} "
if kw:
f_sig += f", {fmt_kw(kw)}"
msg = (
f"{repr_name}={out_shape}, but should be {expected} [{func_name}({f_sig})]"
)
msg = f"{repr_name}={out_shape}, but should be {expected} [{func_name}({f_sig})]"
assert out_shape == expected, msg


Expand Down
Loading