Skip to content

Commit 9816011

Browse files
authored
Merge pull request #109 from honno/stubbing-n-sig-tests
Remove `generate_stubs.py` + hard-coded stubs, change scope of `test_signatures.py`
2 parents 5f2551c + 65117fb commit 9816011

26 files changed

+75
-2123
lines changed

.github/workflows/numpy.yml

+4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ jobs:
4343
# waiting on NumPy to allow/revert distinct NaNs for np.unique
4444
# https://github.com/numpy/numpy/issues/20326#issuecomment-1012380448
4545
array_api_tests/test_set_functions.py
46+
47+
# missing copy arg
48+
array_api_tests/test_signatures.py::test_func_signature[reshape]
49+
4650
# https://github.com/numpy/numpy/issues/21211
4751
array_api_tests/test_special_cases.py::test_iop[__iadd__(x1_i is -0 and x2_i is -0) -> -0]
4852
# https://github.com/numpy/numpy/issues/21213

array_api_tests/_array_module.py

+11-31
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
from importlib import import_module
33

4-
from . import function_stubs
4+
from . import stubs
55

66
# Replace this with a specific array module to test it, for example,
77
#
@@ -53,38 +53,18 @@ def __repr__(self):
5353
__call__ = _raise
5454
__getattr__ = _raise
5555

56-
_integer_dtypes = [
57-
'int8',
58-
'int16',
59-
'int32',
60-
'int64',
61-
'uint8',
62-
'uint16',
63-
'uint32',
64-
'uint64',
65-
]
66-
67-
_floating_dtypes = [
68-
'float32',
69-
'float64',
70-
]
71-
72-
_numeric_dtypes = [
73-
*_integer_dtypes,
74-
*_floating_dtypes,
75-
]
76-
77-
_boolean_dtypes = [
78-
'bool',
79-
]
80-
8156
_dtypes = [
82-
*_boolean_dtypes,
83-
*_numeric_dtypes
57+
"bool",
58+
"uint8", "uint16", "uint32", "uint64",
59+
"int8", "int16", "int32", "int64",
60+
"float32", "float64",
8461
]
62+
_constants = ["e", "inf", "nan", "pi"]
63+
_funcs = [f.__name__ for funcs in stubs.category_to_funcs.values() for f in funcs]
64+
_top_level_attrs = _dtypes + _constants + _funcs + stubs.EXTENSIONS
8565

86-
for func_name in function_stubs.__all__ + _dtypes:
66+
for attr in _top_level_attrs:
8767
try:
88-
globals()[func_name] = getattr(mod, func_name)
68+
globals()[attr] = getattr(mod, attr)
8969
except AttributeError:
90-
globals()[func_name] = _UndefinedStub(func_name)
70+
globals()[attr] = _UndefinedStub(attr)

array_api_tests/function_stubs/__init__.py

-62
This file was deleted.

array_api_tests/function_stubs/_types.py

-41
This file was deleted.

0 commit comments

Comments
 (0)