array-api-extra 0.3.2__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/.all-contributorsrc +11 -0
  2. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/.github/workflows/cd.yml +1 -1
  3. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/.github/workflows/ci.yml +4 -3
  4. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/.github/workflows/docs-build.yml +2 -1
  5. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/.github/workflows/docs-deploy.yml +1 -1
  6. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/.gitignore +7 -1
  7. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/.pre-commit-config.yaml +5 -5
  8. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/CONTRIBUTORS.md +1 -0
  9. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/PKG-INFO +3 -3
  10. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/README.md +1 -0
  11. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/docs/conf.py +1 -3
  12. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/docs/contributing.md +13 -1
  13. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/docs/index.md +63 -17
  14. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/pixi.lock +1681 -3181
  15. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/pyproject.toml +35 -20
  16. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/src/array_api_extra/__init__.py +1 -3
  17. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/src/array_api_extra/_funcs.py +54 -30
  18. array_api_extra-0.4.0/src/array_api_extra/_lib/_compat.py +18 -0
  19. array_api_extra-0.4.0/src/array_api_extra/_lib/_compat.pyi +15 -0
  20. array_api_extra-0.4.0/src/array_api_extra/_lib/_typing.py +8 -0
  21. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/src/array_api_extra/_lib/_utils.py +10 -11
  22. array_api_extra-0.4.0/src/array_api_extra/py.typed +0 -0
  23. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/tests/test_funcs.py +133 -64
  24. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/tests/test_utils.py +14 -7
  25. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/tests/test_version.py +0 -2
  26. array_api_extra-0.4.0/vendor_tests/__init__.py +1 -0
  27. array_api_extra-0.4.0/vendor_tests/_array_api_compat_vendor.py +9 -0
  28. array_api_extra-0.4.0/vendor_tests/test_vendor.py +24 -0
  29. array_api_extra-0.3.2/src/array_api_extra/_lib/_compat.py +0 -168
  30. array_api_extra-0.3.2/src/array_api_extra/_lib/_typing.py +0 -22
  31. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/.gitattributes +0 -0
  32. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/.github/dependabot.yml +0 -0
  33. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/.github/workflows/dependabot-auto-merge.yml +0 -0
  34. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/LICENSE +0 -0
  35. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/codecov.yml +0 -0
  36. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/docs/api-reference.md +0 -0
  37. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/docs/contributors.md +0 -0
  38. {array_api_extra-0.3.2 → array_api_extra-0.4.0}/docs/requirements.txt +0 -0
  39. /array_api_extra-0.3.2/src/array_api_extra/py.typed → /array_api_extra-0.4.0/src/array_api_extra/_lib/__init__.py +0 -0
@@ -163,6 +163,17 @@
163
163
  "contributions": [
164
164
  "code"
165
165
  ]
166
+ },
167
+ {
168
+ "login": "crusaderky",
169
+ "name": "Guido Imperiale",
170
+ "avatar_url": "https://avatars.githubusercontent.com/u/6213168?v=4",
171
+ "profile": "https://github.com/crusaderky",
172
+ "contributions": [
173
+ "code",
174
+ "doc",
175
+ "tool"
176
+ ]
166
177
  }
167
178
  ]
168
179
  }
@@ -37,7 +37,7 @@ jobs:
37
37
  path: dist
38
38
 
39
39
  - name: Generate artifact attestation for sdist and wheel
40
- uses: actions/attest-build-provenance@v1.4.4
40
+ uses: actions/attest-build-provenance@v2.0.1
41
41
  with:
42
42
  subject-path: "dist/*"
43
43
 
@@ -32,8 +32,9 @@ jobs:
32
32
  extra_args: --hook-stage manual --all-files
33
33
  - uses: prefix-dev/setup-pixi@v0.8.1
34
34
  with:
35
- pixi-version: v0.37.0
35
+ pixi-version: v0.39.0
36
36
  cache: true
37
+ environments: lint
37
38
  - name: Run Pylint, Mypy & Pyright
38
39
  run: |
39
40
  pixi run -e lint pylint
@@ -57,7 +58,7 @@ jobs:
57
58
 
58
59
  - uses: prefix-dev/setup-pixi@v0.8.1
59
60
  with:
60
- pixi-version: v0.37.0
61
+ pixi-version: v0.39.0
61
62
  cache: true
62
63
  environments: ${{ matrix.environment }}
63
64
 
@@ -65,6 +66,6 @@ jobs:
65
66
  run: pixi run -e ${{ matrix.environment }} tests-ci
66
67
 
67
68
  - name: Upload coverage report
68
- uses: codecov/codecov-action@v5.0.7
69
+ uses: codecov/codecov-action@v5.1.1
69
70
  with:
70
71
  token: ${{ secrets.CODECOV_TOKEN }}
@@ -9,8 +9,9 @@ jobs:
9
9
  - uses: actions/checkout@v4
10
10
  - uses: prefix-dev/setup-pixi@v0.8.1
11
11
  with:
12
- pixi-version: v0.37.0
12
+ pixi-version: v0.39.0
13
13
  cache: true
14
+ environments: docs
14
15
  - name: Build Docs
15
16
  run: pixi run -e docs docs
16
17
  - name: Upload Artifact
@@ -16,7 +16,7 @@ jobs:
16
16
  steps:
17
17
  - uses: actions/checkout@v4
18
18
  - name: Download Artifact
19
- uses: dawidd6/action-download-artifact@v6
19
+ uses: dawidd6/action-download-artifact@v7
20
20
  with:
21
21
  workflow: docs-build.yml
22
22
  name: docs-build
@@ -114,9 +114,11 @@ ENV/
114
114
  env.bak/
115
115
  venv.bak/
116
116
 
117
- # Spyder project settings
117
+ # IDE project settings
118
+ .idea/
118
119
  .spyderproject
119
120
  .spyproject
121
+ .vscode/
120
122
 
121
123
  # Rope project settings
122
124
  .ropeproject
@@ -160,3 +162,7 @@ Thumbs.db
160
162
  # pixi environments
161
163
  .pixi
162
164
  *.egg-info
165
+
166
+ # Vendor tests
167
+ vendor_tests/array_api_compat/
168
+ vendor_tests/array_api_extra/
@@ -12,7 +12,7 @@ repos:
12
12
  additional_dependencies: [black==24.*]
13
13
 
14
14
  - repo: https://github.com/pre-commit/pre-commit-hooks
15
- rev: "v4.6.0"
15
+ rev: "v5.0.0"
16
16
  hooks:
17
17
  - id: check-added-large-files
18
18
  - id: check-case-conflict
@@ -35,14 +35,14 @@ repos:
35
35
  - id: rst-inline-touching-normal
36
36
 
37
37
  - repo: https://github.com/rbubley/mirrors-prettier
38
- rev: "v3.3.3"
38
+ rev: "v3.4.2"
39
39
  hooks:
40
40
  - id: prettier
41
41
  types_or: [yaml, markdown, html, css, scss, javascript, json]
42
42
  args: [--prose-wrap=always]
43
43
 
44
44
  - repo: https://github.com/astral-sh/ruff-pre-commit
45
- rev: "v0.6.1"
45
+ rev: "v0.8.2"
46
46
  hooks:
47
47
  - id: ruff
48
48
  args: ["--fix", "--show-fixes"]
@@ -68,13 +68,13 @@ repos:
68
68
  exclude: .pre-commit-config.yaml
69
69
 
70
70
  - repo: https://github.com/abravalheri/validate-pyproject
71
- rev: "v0.19"
71
+ rev: "v0.23"
72
72
  hooks:
73
73
  - id: validate-pyproject
74
74
  additional_dependencies: ["validate-pyproject-schema-store[all]"]
75
75
 
76
76
  - repo: https://github.com/python-jsonschema/check-jsonschema
77
- rev: "0.29.1"
77
+ rev: "0.30.0"
78
78
  hooks:
79
79
  - id: check-dependabot
80
80
  - id: check-github-workflows
@@ -28,6 +28,7 @@ This project exists thanks to the following contributors
28
28
  </tr>
29
29
  <tr>
30
30
  <td align="center" valign="top" width="14.28%"><a href="https://ogrisel.com"><img src="https://avatars.githubusercontent.com/u/89061?v=4?s=100" width="100px;" alt="Olivier Grisel"/><br /><sub><b>Olivier Grisel</b></sub></a><br /><a href="https://github.com/data-apis/array-api-extra/commits?author=ogrisel" title="Code">💻</a></td>
31
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/crusaderky"><img src="https://avatars.githubusercontent.com/u/6213168?v=4?s=100" width="100px;" alt="Guido Imperiale"/><br /><sub><b>Guido Imperiale</b></sub></a><br /><a href="https://github.com/data-apis/array-api-extra/commits?author=crusaderky" title="Code">💻</a> <a href="https://github.com/data-apis/array-api-extra/commits?author=crusaderky" title="Documentation">📖</a> <a href="#tool-crusaderky" title="Tools">🔧</a></td>
31
32
  </tr>
32
33
  </tbody>
33
34
  </table>
@@ -1,12 +1,10 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: array-api-extra
3
- Version: 0.3.2
3
+ Version: 0.4.0
4
4
  Summary: Extra array functions built on top of the array API standard.
5
5
  Project-URL: Homepage, https://github.com/data-apis/array-api-extra
6
6
  Project-URL: Bug Tracker, https://github.com/data-apis/array-api-extra/issues
7
- Project-URL: Discussions, https://github.com/data-apis/array-api-extra/discussions
8
7
  Project-URL: Changelog, https://github.com/data-apis/array-api-extra/releases
9
- Author: Open Source Contributors
10
8
  Author-email: Lucas Colley <lucas.colley8@gmail.com>
11
9
  License: MIT License
12
10
 
@@ -41,6 +39,7 @@ Classifier: Programming Language :: Python :: 3.12
41
39
  Classifier: Programming Language :: Python :: 3.13
42
40
  Classifier: Typing :: Typed
43
41
  Requires-Python: >=3.10
42
+ Requires-Dist: array-api-compat>=1.1.1
44
43
  Provides-Extra: docs
45
44
  Requires-Dist: furo>=2023.08.17; extra == 'docs'
46
45
  Requires-Dist: myst-parser>=0.13; extra == 'docs'
@@ -122,6 +121,7 @@ This project exists thanks to the following contributors
122
121
  </tr>
123
122
  <tr>
124
123
  <td align="center" valign="top" width="14.28%"><a href="https://ogrisel.com"><img src="https://avatars.githubusercontent.com/u/89061?v=4?s=100" width="100px;" alt="Olivier Grisel"/><br /><sub><b>Olivier Grisel</b></sub></a><br /><a href="https://github.com/data-apis/array-api-extra/commits?author=ogrisel" title="Code">💻</a></td>
124
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/crusaderky"><img src="https://avatars.githubusercontent.com/u/6213168?v=4?s=100" width="100px;" alt="Guido Imperiale"/><br /><sub><b>Guido Imperiale</b></sub></a><br /><a href="https://github.com/data-apis/array-api-extra/commits?author=crusaderky" title="Code">💻</a> <a href="https://github.com/data-apis/array-api-extra/commits?author=crusaderky" title="Documentation">📖</a> <a href="#tool-crusaderky" title="Tools">🔧</a></td>
125
125
  </tr>
126
126
  </tbody>
127
127
  </table>
@@ -66,6 +66,7 @@ This project exists thanks to the following contributors
66
66
  </tr>
67
67
  <tr>
68
68
  <td align="center" valign="top" width="14.28%"><a href="https://ogrisel.com"><img src="https://avatars.githubusercontent.com/u/89061?v=4?s=100" width="100px;" alt="Olivier Grisel"/><br /><sub><b>Olivier Grisel</b></sub></a><br /><a href="https://github.com/data-apis/array-api-extra/commits?author=ogrisel" title="Code">💻</a></td>
69
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/crusaderky"><img src="https://avatars.githubusercontent.com/u/6213168?v=4?s=100" width="100px;" alt="Guido Imperiale"/><br /><sub><b>Guido Imperiale</b></sub></a><br /><a href="https://github.com/data-apis/array-api-extra/commits?author=crusaderky" title="Code">💻</a> <a href="https://github.com/data-apis/array-api-extra/commits?author=crusaderky" title="Documentation">📖</a> <a href="#tool-crusaderky" title="Tools">🔧</a></td>
69
70
  </tr>
70
71
  </tbody>
71
72
  </table>
@@ -1,5 +1,3 @@
1
- from __future__ import annotations
2
-
3
1
  import importlib.metadata
4
2
  from typing import Any
5
3
 
@@ -38,7 +36,7 @@ html_theme_options: dict[str, Any] = {
38
36
  <svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
39
37
  <path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
40
38
  </svg>
41
- """,
39
+ """, # noqa: E501
42
40
  "class": "",
43
41
  },
44
42
  ],
@@ -43,13 +43,25 @@ pixi shell -e dev
43
43
  pixi run tests
44
44
  ```
45
45
 
46
+ - To generate the coverage report:
47
+
48
+ ```
49
+ pixi run coverage
50
+ ```
51
+
52
+ - To generate and display the coverage report:
53
+
54
+ ```
55
+ pixi run open-coverage
56
+ ```
57
+
46
58
  - To build the docs locally:
47
59
 
48
60
  ```
49
61
  pixi run docs
50
62
  ```
51
63
 
52
- - To open and preview the locally-built docs:
64
+ - To build and preview the docs locally:
53
65
 
54
66
  ```
55
67
  pixi run open-docs
@@ -40,7 +40,7 @@ And
40
40
  [on conda-forge](https://prefix.dev/channels/conda-forge/packages/array-api-extra):
41
41
 
42
42
  ```shell
43
- micromamba install -c https://repo.prefix.dev/conda-forge array-api-extra
43
+ mamba install array-api-extra
44
44
  # or
45
45
  pixi add array-api-extra
46
46
  ```
@@ -51,16 +51,57 @@ If you require stability, it is recommended to pin `array-api-extra` to
51
51
  a specific version, or vendor the library inside your own.
52
52
  ```
53
53
 
54
+ ```{note}
55
+ This library depends on array-api-compat. We aim for compatibility with
56
+ the latest released version of array-api-compat, and your mileage may vary
57
+ with older or dev versions.
58
+ ```
59
+
54
60
  (vendoring)=
55
61
 
56
62
  ## Vendoring
57
63
 
58
64
  To vendor the library, clone
59
- [the repository](https://github.com/data-apis/array-api-extra) and copy it into
60
- the appropriate place in your library, like:
65
+ [the array-api-extra repository](https://github.com/data-apis/array-api-extra)
66
+ and copy it into the appropriate place in your library, like:
61
67
 
62
68
  ```
63
- cp -R array-api-extra/ mylib/vendored/array_api_extra
69
+ cp -a array-api-extra/src/array_api_extra mylib/vendored/
70
+ ```
71
+
72
+ `array-api-extra` depends on `array-api-compat`. You may either add a dependency
73
+ in your own project to `array-api-compat` or vendor it too:
74
+
75
+ 1. Clone
76
+ [the array-api-compat repository](https://github.com/data-apis/array-api-compat)
77
+ and copy it next to your vendored array-api-extra:
78
+
79
+ ```
80
+ cp -a array-api-compat/array_api_compat mylib/vendored/
81
+ ```
82
+
83
+ 2. Create a new hook file which array-api-extra will use instead of the
84
+ top-level `array-api-compat` if present:
85
+
86
+ ```
87
+ echo 'from mylib.vendored.array_api_compat import *' > mylib/vendored/_array_api_compat_vendor.py
88
+ ```
89
+
90
+ This also allows overriding `array-api-compat` functions if you so wish. E.g.
91
+ your `mylib/vendored/_array_api_compat_vendor.py` could look like this:
92
+
93
+ ```python
94
+ from mylib.vendored.array_api_compat import *
95
+ from mylib.vendored.array_api_compat import array_namespace as _array_namespace_orig
96
+
97
+
98
+ def array_namespace(*xs, **kwargs):
99
+ import mylib
100
+
101
+ if any(isinstance(x, mylib.MyArray) for x in xs):
102
+ return mylib
103
+ else:
104
+ return _array_namespace_orig(*xs, **kwargs)
64
105
  ```
65
106
 
66
107
  (usage)=
@@ -81,9 +122,12 @@ return xpx.atleast_nd(y, ndim=2, xp=xp)
81
122
 
82
123
  ```{note}
83
124
  Functions in this library assume input arrays *are arrays* (not "array-likes") and that
84
- the namespace passed as `xp` is compatible with the standard. This means that
85
- the namespace you pass as `xp` should come from array-api-compat's ``array_namespace``,
125
+ the namespace passed as `xp` (if given) is compatible with the standard -
126
+ this means that it should come from array-api-compat's `array_namespace`,
86
127
  or otherwise be compatible with the standard.
128
+
129
+ Calling functions without providing an `xp` argument means that `array_namespace`
130
+ is called internally to determine the namespace.
87
131
  ```
88
132
 
89
133
  In the examples shown in the docstrings of functions from this library,
@@ -92,6 +136,9 @@ array namespace `xp`. In reality, code using this library will be written to
92
136
  work with any compatible array namespace as `xp`, not any particular
93
137
  implementation.
94
138
 
139
+ Some functions may only work with array libraries supported by array-api-compat.
140
+ This will be clearly indicated in the docs.
141
+
95
142
  (scope)=
96
143
 
97
144
  ## Scope
@@ -102,11 +149,15 @@ Functions that are in-scope for this library will:
102
149
  standard.
103
150
  - Implement functionality which may be generally useful across various
104
151
  libraries.
105
- - Be implemented purely in terms of the array API standard.
106
152
  - Be implemented with type annotations and
107
153
  [numpydoc-style docstrings](https://numpydoc.readthedocs.io/en/latest/format.html).
108
154
  - Be tested against `array-api-strict`.
109
155
 
156
+ Functions are implemented purely in terms of the array API standard where
157
+ possible. Where functions must use library-specific helpers for libraries
158
+ supported by array-api-compat, this will be clearly marked in their API
159
+ reference page.
160
+
110
161
  In particular, the following kinds of function are also in-scope:
111
162
 
112
163
  - Functions which implement
@@ -117,20 +168,15 @@ In particular, the following kinds of function are also in-scope:
117
168
 
118
169
  The following features are currently out-of-scope for this library:
119
170
 
120
- - Delegation to known, existing array libraries.
171
+ - Delegation to known, existing array libraries (unless necessary).
121
172
  - It is quite simple to wrap functions in this library to also use existing
122
- implementations where possible. Such delegation will not live in this
123
- library for now, but the array-agnostic functions in this library could form
124
- an array-agnostic backend for such delegating functions in the future, here
125
- or elsewhere.
173
+ implementations. Such delegation will not live in this library for now, but
174
+ the array-agnostic functions in this library could form an array-agnostic
175
+ backend for such delegating functions in the future, here or elsewhere.
126
176
  - Functions which accept "array-like" input, or standard-incompatible
127
177
  namespaces.
128
178
  - It is possible to prepare input arrays and a standard-compatible namespace
129
- via `array-api-compat` downstream in consumer libraries. Avoiding use of
130
- `array-api-compat` in this library makes it easier to vendor and reduces
131
- potential redundant calls to `xp.asarray` and `array_namespace`.
132
- - For proposed alternatives to the `xp=xp` interface, see
133
- [this issue](https://github.com/data-apis/array-api-extra/issues/6).
179
+ via `array-api-compat` downstream in consumer libraries.
134
180
  - Functions which are specific to a particular domain.
135
181
  - These functions may belong better in an array-consuming library which is
136
182
  specific to that domain.