Skip to content

Commit c3c229f

Browse files
committed
Merge branch 'main' into apply
2 parents ea68ed8 + 45b64d2 commit c3c229f

File tree

10 files changed

+1651
-1518
lines changed

10 files changed

+1651
-1518
lines changed

docs/contributing.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ converting code to consume the standard.
66

77
Thanks to [all contributors](contributors.md) so far!
88

9-
## How to contribute a function
9+
## How to contribute a new function
1010

1111
- [Open an issue](https://github.com/data-apis/array-api-extra/issues/new) to
12-
propose the new function.
13-
- Add the implementation of your function to `src/array_api_extra/_funcs.py`.
12+
propose the new function. You may want to wait for initial feedback on the
13+
issue before diving into an implementation. Feel free to skip this step if
14+
there is already an open issue for the function.
15+
- Add the implementation of your function to
16+
`src/array_api_extra/_lib/_funcs.py`.
1417
- Ensure that your function includes type annotations and a
1518
[numpydoc-style docstring](https://numpydoc.readthedocs.io/en/latest/format.html).
1619
- Add your function to `__all__` at the top of the file.
@@ -20,6 +23,33 @@ Thanks to [all contributors](contributors.md) so far!
2023
- Add your function to `docs/api-reference.md`.
2124
- [Make a PR!](https://github.com/data-apis/array-api-extra/pulls)
2225

26+
## How to add delegation to a function
27+
28+
See [the tracker for adding delegation][delegation-tracker].
29+
30+
[delegation-tracker]: https://github.com/data-apis/array-api-extra/issues/100
31+
32+
- If you would like to discuss the task before diving into the implementation,
33+
click on the three dots next to the function on the tracker issue, and choose
34+
"Convert to sub-issue".
35+
- Create a function in `src/array_api_extra/_delegation.py` with a signature
36+
matching the function in `src/array_api_extra/_lib/_funcs.py`, and move the
37+
docstring to the new function. Leave a one-line docstring in `_funcs.py`,
38+
pointing to `_delegation.py` to see the full docstring.
39+
- Also move the initial `array_namespace` call and any input validation over to
40+
the new function.
41+
- Add delegation to backends using the `if _delegate` pattern. See
42+
`src/array_api_extra/_lib/_backends.py` for the full list of backends we have
43+
worked with so far.
44+
- After all delegation layers, return the result from the implementation in
45+
`_funcs`.
46+
- Simplify the signature in `_funcs.py` to remove impossible arguments now that
47+
it is only called internally via `_delegation`. For example, the `xp`
48+
parameter can be changed from type `ModuleType | None` to `ModuleType`.
49+
- Don't worry if you are not sure how to do some of the above steps or think you
50+
might have done something wrong -
51+
[make a PR!](https://github.com/data-apis/array-api-extra/pulls)
52+
2353
## Development workflow
2454

2555
If you are an experienced contributor to Python packages, feel free to develop

pixi.lock

Lines changed: 1066 additions & 941 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 15 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,6 @@ classifiers = [
2828
dynamic = ["version"]
2929
dependencies = ["array-api-compat>=1.10.0,<2"]
3030

31-
[project.optional-dependencies]
32-
tests = [
33-
"pytest >=6",
34-
"pytest-cov >=3",
35-
"array-api-strict",
36-
"numpy",
37-
]
38-
docs = [
39-
"sphinx>=7.0",
40-
"myst_parser>=0.13",
41-
"sphinx_copybutton",
42-
"sphinx_autodoc_typehints",
43-
"furo>=2023.08.17",
44-
]
45-
4631
[project.urls]
4732
Homepage = "https://github.com/data-apis/array-api-extra"
4833
"Bug Tracker" = "https://github.com/data-apis/array-api-extra/issues"
@@ -168,7 +153,7 @@ cupy = "*"
168153

169154
[tool.pixi.environments]
170155
default = { solve-group = "default" }
171-
lint = { features = ["lint"], solve-group = "default" }
156+
lint = { features = ["lint", "backends"], solve-group = "default" }
172157
tests = { features = ["tests"], solve-group = "default" }
173158
docs = { features = ["docs"], solve-group = "default" }
174159
dev = { features = ["lint", "tests", "docs", "dev", "backends"], solve-group = "default" }
@@ -179,30 +164,24 @@ ci-py313 = ["py313", "tests"]
179164
ci-backends = ["py310", "tests", "backends"]
180165
tests-backends = ["py310", "tests", "backends", "cuda-backends"]
181166

167+
182168
# pytest
183169

184170
[tool.pytest.ini_options]
185171
minversion = "6.0"
186172
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
187173
xfail_strict = true
188-
filterwarnings = [
189-
"error",
190-
# TODO: when Python 3.10 is dropped, use `enum.member` in `_delegation.py`
191-
"ignore:functools.partial will be a method descriptor:FutureWarning",
192-
]
174+
filterwarnings = ["error"]
193175
log_cli_level = "INFO"
194176
testpaths = ["tests"]
195177
markers = ["skip_xp_backend(library, *, reason=None): Skip test for a specific backend"]
196178

179+
197180
# Coverage
198181

199182
[tool.coverage]
200183
run.source = ["array_api_extra"]
201-
report.exclude_also = [
202-
'\.\.\.',
203-
'if typing.TYPE_CHECKING:',
204-
'if TYPE_CHECKING:',
205-
]
184+
report.exclude_also = ['\.\.\.']
206185

207186

208187
# mypy
@@ -213,18 +192,11 @@ python_version = "3.10"
213192
warn_unused_configs = true
214193
strict = true
215194
enable_error_code = ["ignore-without-code", "truthy-bool"]
216-
disallow_untyped_defs = false
217-
disallow_incomplete_defs = false
218-
# data-apis/array-api#589
195+
# https://github.com/data-apis/array-api-typing
219196
disallow_any_expr = false
220197
# false positives with input validation
221198
disable_error_code = ["redundant-expr", "unreachable"]
222199

223-
[[tool.mypy.overrides]]
224-
module = "array_api_extra.*"
225-
disallow_untyped_defs = true
226-
disallow_incomplete_defs = true
227-
228200

229201
# pyright
230202

@@ -234,10 +206,10 @@ pythonVersion = "3.10"
234206
pythonPlatform = "All"
235207
typeCheckingMode = "all"
236208

237-
# data-apis/array-api#589
209+
# https://github.com/data-apis/array-api-typing
238210
reportAny = false
239211
reportExplicitAny = false
240-
# data-apis/array-api-strict#6
212+
# no array-api-strict type stubs
241213
reportUnknownMemberType = false
242214
# no array-api-compat type stubs
243215
reportUnknownVariableType = false
@@ -294,25 +266,17 @@ ignore = [
294266
"N806", # Variable in function should be lowercase
295267
]
296268

297-
[tool.ruff.lint.per-file-ignores]
298-
"tests/**" = ["T20"]
299-
300269

301270
# Pylint
302271

303272
[tool.pylint]
304273
py-version = "3.10"
305-
ignore-paths = [".*/_version.py"]
306274
reports.output-format = "colorized"
307-
similarities.ignore-imports = "yes"
308275
messages_control.disable = [
309-
"design",
310-
"fixme",
311-
"line-too-long",
312-
"missing-module-docstring",
313-
"missing-function-docstring",
314-
"too-many-lines",
315-
"wrong-import-position",
276+
"design", # ignore heavily opinionated design checks
277+
"fixme", # allow FIXME comments
278+
"line-too-long", # ruff handles this
279+
"missing-function-docstring", # numpydoc handles this
316280
]
317281

318282

@@ -321,9 +285,9 @@ messages_control.disable = [
321285
[tool.numpydoc_validation]
322286
checks = [
323287
"all", # report on all checks, except the below
324-
"EX01",
325-
"SA01",
326-
"ES01",
288+
"EX01", # most docstrings do not need an example
289+
"SA01", # data-apis/array-api-extra#87
290+
"ES01", # most docstrings do not need an extended summary
327291
]
328292
exclude = [ # don't report on objects that match any of these regex
329293
'.*test_at.*',

src/array_api_extra/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""Extra array functions built on top of the array API standard."""
22

33
from ._delegation import pad
4+
from ._lib._at import at
45
from ._lib._funcs import (
5-
at,
66
atleast_nd,
77
cov,
88
create_diagonal,

0 commit comments

Comments
 (0)