|
4 | 4 | :maxdepth: 2
|
5 | 5 | :hidden:
|
6 | 6 | api-reference.md
|
| 7 | +contributing.md |
7 | 8 | ```
|
8 | 9 |
|
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) |
11 | 62 | ```
|
| 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