Skip to content

Commit 7596e8b

Browse files
authored
Merge pull request #8 from lucascolley/docs
2 parents 2b85108 + c610deb commit 7596e8b

File tree

2 files changed

+183
-2
lines changed

2 files changed

+183
-2
lines changed

docs/contributing.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Contributing
2+
3+
Contributions are welcome from any "array-consuming" library contributors who
4+
have found themselves writing private array-agnostic functions in the process of
5+
converting code to consume the standard!
6+
7+
## How to contribute a function
8+
9+
- Add the implementation of your function to `src/array_api_extra/_funcs.py`.
10+
- Ensure that your function includes type annotations and a
11+
[numpydoc-style docstring](https://numpydoc.readthedocs.io/en/latest/format.html).
12+
- Add your function to `__all__` at the top of the file.
13+
- Import your function to `src/array_api_extra/__init__.py` and add it to
14+
`__all__` there.
15+
- Add a test class for your function in `tests/test_funcs.py`.
16+
- [Make a PR!](https://github.com/data-apis/array-api-extra/pulls)
17+
18+
## Development workflow
19+
20+
If you are an experienced contributor to Python packages, feel free to develop
21+
however you feel comfortable! However, if you would like some guidance,
22+
development of array-api-extra is made easy with
23+
[Pixi](https://pixi.sh/latest/):
24+
25+
- [Clone the repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository)
26+
at <https://github.com/data-apis/array-api-extra>.
27+
- `cd array-api-extra`.
28+
- [Install Pixi](https://pixi.sh/latest/#installation).
29+
- To enter a development environment:
30+
31+
```
32+
pixi shell -e dev
33+
```
34+
35+
- To run the tests:
36+
37+
```
38+
pixi run test
39+
```
40+
41+
- To build the docs locally:
42+
43+
```
44+
pixi run docs
45+
```
46+
47+
- To install a [pre-commit](https://pre-commit.com) hook and run the lint suite:
48+
49+
```
50+
pixi run lint
51+
```
52+
53+
- To enter an interactive Python prompt:
54+
55+
```
56+
pixi run ipython
57+
```
58+
59+
- To run individual parts of the lint suite separately:
60+
61+
```
62+
pixi run pre-commit
63+
pixi run pylint
64+
pixi run mypy
65+
```
66+
67+
Alternative environments are available with a subset of the dependencies and
68+
tasks available in the `dev` environment:
69+
70+
```
71+
pixi shell -e docs
72+
pixi shell -e test
73+
pixi shell -e lint
74+
```

docs/index.md

Lines changed: 109 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,115 @@
44
:maxdepth: 2
55
:hidden:
66
api-reference.md
7+
contributing.md
78
```
89

9-
```{include} ../README.md
10-
:start-after: <!-- SPHINX-START -->
10+
This is a library housing "array-agnostic" implementations of functions built on
11+
top of [the Python array API standard](https://data-apis.org/array-api/).
12+
13+
The intended users of this library are "array-consuming" libraries which are
14+
using [array-api-compat](https://data-apis.org/array-api-compat/) to make their
15+
own library's functions array-agnostic. In this library, they will find a set of
16+
tools which provide _extra_ functionality on top of the array API standard,
17+
which other array-consuming libraries in a similar position have found useful
18+
themselves.
19+
20+
(installation)=
21+
22+
## Installation
23+
24+
`array-api-extra` is available
25+
[on PyPI](https://pypi.org/project/array-api-extra/):
26+
27+
```shell
28+
python -m pip install array-api-extra
29+
```
30+
31+
(vendoring)=
32+
33+
## Vendoring
34+
35+
```{warning}
36+
This library currently provides no backwards-compatibility guarantees!
37+
If you require stability, it is recommended to vendor this library inside your own.
38+
```
39+
40+
To vendor the library, clone
41+
[the repository](https://github.com/data-apis/array-api-extra) and copy
42+
`array_api_extra` into the appropriate place in your library, like:
43+
44+
```
45+
cp -R array_api_extra/ mylib/vendored/array_api_extra
46+
```
47+
48+
(usage)=
49+
50+
## Usage
51+
52+
Typical usage of this library looks like:
53+
54+
```python
55+
import array_api_strict as xpx
56+
57+
...
58+
xp = array_namespace(x)
59+
y = xp.sum(x)
60+
...
61+
return xpx.atleast_nd(y, ndim=2, xp=xp)
1162
```
63+
64+
```{note}
65+
Functions in this library assume input arrays *are arrays* (not "array-likes") and that
66+
the namespace passed as `xp` is compatible with the standard. This means that
67+
the namespace you pass as `xp` should come from array-api-compat's ``array_namespace``,
68+
or otherwise be compatible with the standard.
69+
```
70+
71+
In the examples shown in the docstrings of functions from this library,
72+
[`array-api-strict`](https://data-apis.org/array-api-strict/) is used as the
73+
array namespace `xp`. In reality, code using this library will be written to
74+
work with any compatible array namespace as `xp`, not any particular
75+
implementation.
76+
77+
(scope)=
78+
79+
## Scope
80+
81+
Functions that are in-scope for this library will:
82+
83+
- Implement functionality which does not already exist in the array API
84+
standard.
85+
- Implement functionality which may be generally useful across various
86+
libraries.
87+
- Be implemented purely in terms of the array API standard.
88+
- Be implemented with type annotations and
89+
[numpydoc-style docstrings](https://numpydoc.readthedocs.io/en/latest/format.html).
90+
- Be tested against `array-api-strict`.
91+
92+
In particular, the following kinds of function are also in-scope:
93+
94+
- Functions which implement
95+
[array API standard extension](https://data-apis.org/array-api/2023.12/extensions/index.html)
96+
functions in terms of functions from the base standard.
97+
- Functions which add functionality (e.g. extra parameters) to functions from
98+
the standard.
99+
100+
The following features are currently out-of-scope for this library:
101+
102+
- Delegation to known, existing array libraries.
103+
- It is quite simple to wrap functions in this library to also use existing
104+
implementations where possible. Such delegation will not live in this
105+
library for now, but the array-agnostic functions in this library could form
106+
an array-agnostic backend for such delegating functions in the future, here
107+
or elsewhere.
108+
- Functions which accept "array-like" input, or standard-incompatible
109+
namespaces.
110+
- It is possible to prepare input arrays and a standard-compatible namespace
111+
via `array-api-compat` downstream in consumer libraries. Avoiding use of
112+
`array-api-compat` in this library makes it easier to vendor and reduces
113+
potential redundant calls to `xp.asarray` and `array_namespace`.
114+
- For proposed alternatives to the `xp=xp` interface, see
115+
[this issue](https://github.com/data-apis/array-api-extra/issues/6).
116+
- Functions which are specific to a particular domain.
117+
- These functions may belong better in an array-consuming library which is
118+
specific to that domain.

0 commit comments

Comments
 (0)