Better signature tests for required arguments
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start by locating the signature tests and the specified_kwargs() helper mentioned in the issue, then run their existing tests to understand current behavior. Done means signatures with extra required positional arguments fail, while optional positional arguments are tested both positionally and by keyword.
Written by the indexing model from the issue text.
Description
This signature tests do not properly check for cases where a function has more required positional arguments than it should. Such a case should be considered noncompliant, since user code written against the standard signature would not function. For example, if the standard has a function
def f(x, y=None):
...
then a function
def f(x, y):
...
should fail the signature test, because code like f(a) should work according to the standard but it wouldn't in the implementation.
Practically speaking, this would help me catch bugs with the xp signature logic in array-api-compat (see https://data-apis.org/array-api-compat/dev/implementation-notes.html). For instance, I accidentally wrote
def clip(
x: ndarray,
/,
xp,
min: Optional[Union[int, float, ndarray]] = None,
max: Optional[Union[int, float, ndarray]] = None,
) -> ndarray:
but it should have been
def clip(
x: ndarray,
/,
min: Optional[Union[int, float, ndarray]] = None,
max: Optional[Union[int, float, ndarray]] = None,
*,
xp,
) -> ndarray:
The former works if you pass min and max as keywords but not if you pass them positionally (array-api-compat has a decorator that automatically injects the xp keyword argument into the final signature).
Additionally, some helpers to test optional positional arguments as both positional and keyword in the test itself would be useful. Right now we have specified_kwargs() but it doesn't allow passing the arguments as positional.
- Dominant language
- Python
- Stars
- 74
- Forks
- 54
- Avg merge
- 4h 35m
- Merged PRs (30d)
- 4
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from data-apis/array-api-tests
-
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
data-apis/array-api-tests#465 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
data-apis/array-api-tests#460 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
data-apis/array-api-tests#455 · 2 comments ·
-
tracking
Difficulty 5/5 Over a week Newbie friendliness 25/100
data-apis/array-api-tests#381 · 9 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 38/100
data-apis/array-api-tests#379 · 10 comments ·
All issues in data-apis/array-api-tests
Similar issues
-
essnmx good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
[Feature] 奇物选择添加优先级 Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
syfoud/Simulated_Scepter#174 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Giskard-AI/giskard-oss#2840 · 1 comment ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Openarea: repo bug perceived difficulty: 2
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
yeti-platform/yeti#1380 ·