|
| 1 | +""" |
| 2 | +A NumPy sub-namespace that conforms to the Python array API standard. |
| 3 | +
|
| 4 | +This is a proof-of-concept namespace that wraps the corresponding NumPy |
| 5 | +functions to give a conforming implementation of the Python array API standard |
| 6 | +(https://data-apis.github.io/array-api/latest/). The standard is currently in |
| 7 | +an RFC phase and comments on it are both welcome and encouraged. Comments |
| 8 | +should be made either at https://github.com/data-apis/array-api or at |
| 9 | +https://github.com/data-apis/consortium-feedback/discussions. |
| 10 | +
|
| 11 | +This submodule will be accompanied with a NEP (not yet written) proposing its |
| 12 | +inclusion in NumPy. |
| 13 | +
|
| 14 | +NumPy already follows the proposed spec for the most part, so this module |
| 15 | +serves mostly as a thin wrapper around it. However, NumPy also implements a |
| 16 | +lot of behavior that is not included in the spec, so this serves as a |
| 17 | +restricted subset of the API. Only those functions that are part of the spec |
| 18 | +are included in this namespace, and all functions are given with the exact |
| 19 | +signature given in the spec, including the use of position-only arguments, and |
| 20 | +omitting any extra keyword arguments implemented by NumPy but not part of the |
| 21 | +spec. Note that the array object itself is unchanged, as implementing a |
| 22 | +restricted subclass of ndarray seems unnecessarily complex for the purposes of |
| 23 | +this namespace, so the API of array methods and other behaviors of the array |
| 24 | +object will include things that are not part of the spec. |
| 25 | +
|
| 26 | +The spec is designed as a "minimal API subset" and explicitly allows libraries |
| 27 | +to include behaviors not specified by it. But users of this module that intend |
| 28 | +to write portable code should be aware that only those behaviors that are |
| 29 | +listed in the spec are guaranteed to be implemented across libraries. |
| 30 | +
|
| 31 | +A few notes about the current state of this submodule: |
| 32 | +
|
| 33 | +- There is a test suite that tests modules against the array API standard at |
| 34 | + https://github.com/data-apis/array-api-tests. The test suite is still a work |
| 35 | + in progress, but the existing tests pass on this module, with a few |
| 36 | + exceptions: |
| 37 | +
|
| 38 | + - Device support is not yet implemented in NumPy |
| 39 | + (https://data-apis.github.io/array-api/latest/design_topics/device_support.html). |
| 40 | + As a result, the `device` attribute of the array object is missing, and |
| 41 | + array creation functions that take the `device` keyword argument will fail |
| 42 | + with NotImplementedError. |
| 43 | +
|
| 44 | + - DLPack support (see https://github.com/data-apis/array-api/pull/106) is |
| 45 | + not included here, as it requires a full implementation in NumPy proper |
| 46 | + first. |
| 47 | +
|
| 48 | + - np.argmin and np.argmax do not implement the keepdims keyword argument. |
| 49 | +
|
| 50 | + - Some linear algebra functions in the spec are still a work in progress (to |
| 51 | + be added soon). These will be updated once the spec is. |
| 52 | +
|
| 53 | + - Some tests in the test suite are still not fully correct in that they test |
| 54 | + all datatypes whereas certain functions are only defined for a subset of |
| 55 | + datatypes. |
| 56 | +
|
| 57 | + The test suite is yet complete, and even the tests that exist are not |
| 58 | + guaranteed to give a comprehensive coverage of the spec. Therefore, those |
| 59 | + reviewing this submodule should refer to the standard documents themselves. |
| 60 | +
|
| 61 | +- All places where the implementations in this submodule are known to deviate |
| 62 | + from their corresponding functions in NumPy are marked with "# Note" |
| 63 | + comments. Reviewers should make note of these comments. |
| 64 | +
|
| 65 | +""" |
| 66 | + |
1 | 67 | __all__ = []
|
2 | 68 |
|
3 | 69 | from ._constants import e, inf, nan, pi
|
|
0 commit comments