array-api-extra 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,7 @@
1
+ from __future__ import annotations
2
+
3
+ from ._funcs import atleast_nd
4
+
5
+ __version__ = "0.1.0"
6
+
7
+ __all__ = ["__version__", "atleast_nd"]
@@ -0,0 +1,48 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ if TYPE_CHECKING:
6
+ from ._typing import Array, ModuleType
7
+
8
+ __all__ = ["atleast_nd"]
9
+
10
+
11
+ def atleast_nd(x: Array, *, ndim: int, xp: ModuleType) -> Array:
12
+ """
13
+ Recursively expand the dimension of an array to at least `ndim`.
14
+
15
+ Parameters
16
+ ----------
17
+ x : array
18
+ ndim : int
19
+ The minimum number of dimensions for the result.
20
+ xp : array_namespace
21
+ The standard-compatible namespace for `x`.
22
+
23
+ Returns
24
+ -------
25
+ res : array
26
+ An array with ``res.ndim`` >= `ndim`.
27
+ If ``x.ndim`` >= `ndim`, `x` is returned.
28
+ If ``x.ndim`` < `ndim`, `x` is expanded by prepending new axes
29
+ until ``res.ndim`` equals `ndim`.
30
+
31
+ Examples
32
+ --------
33
+ >>> import array_api_strict as xp
34
+ >>> import array_api_extra as xpx
35
+ >>> x = xp.asarray([1])
36
+ >>> xpx.atleast_nd(x, ndim=3, xp=xp)
37
+ Array([[[1]]], dtype=array_api_strict.int64)
38
+
39
+ >>> x = xp.asarray([[[1, 2],
40
+ ... [3, 4]]])
41
+ >>> xpx.atleast_nd(x, ndim=1, xp=xp) is x
42
+ True
43
+
44
+ """
45
+ if x.ndim < ndim:
46
+ x = xp.expand_dims(x, axis=0)
47
+ x = atleast_nd(x, ndim=ndim, xp=xp)
48
+ return x
@@ -0,0 +1,9 @@
1
+ from __future__ import annotations
2
+
3
+ from types import ModuleType
4
+ from typing import TYPE_CHECKING, Any
5
+
6
+ if TYPE_CHECKING:
7
+ Array = Any # To be changed to a Protocol later (see array-api#589)
8
+
9
+ __all__ = ["Array", "ModuleType"]
File without changes
@@ -0,0 +1,85 @@
1
+ Metadata-Version: 2.3
2
+ Name: array-api-extra
3
+ Version: 0.1.0
4
+ Summary: Extra array functions that aren't in the array API standard, implemented in terms of the standard.
5
+ Project-URL: Homepage, https://github.com/data-apis/array-api-extra
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
+ Project-URL: Changelog, https://github.com/data-apis/array-api-extra/releases
9
+ Author: Open Source Contributors
10
+ Author-email: Lucas Colley <lucas.colley8@gmail.com>
11
+ License: MIT License
12
+
13
+ Copyright (c) 2024 Consortium for Python Data API Standards
14
+
15
+ Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ of this software and associated documentation files (the "Software"), to deal
17
+ in the Software without restriction, including without limitation the rights
18
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ copies of the Software, and to permit persons to whom the Software is
20
+ furnished to do so, subject to the following conditions:
21
+
22
+ The above copyright notice and this permission notice shall be included in all
23
+ copies or substantial portions of the Software.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
+ SOFTWARE.
32
+ License-File: LICENSE
33
+ Classifier: Intended Audience :: Developers
34
+ Classifier: License :: OSI Approved :: MIT License
35
+ Classifier: Operating System :: OS Independent
36
+ Classifier: Programming Language :: Python
37
+ Classifier: Programming Language :: Python :: 3
38
+ Classifier: Programming Language :: Python :: 3 :: Only
39
+ Classifier: Programming Language :: Python :: 3.9
40
+ Classifier: Programming Language :: Python :: 3.10
41
+ Classifier: Programming Language :: Python :: 3.11
42
+ Classifier: Programming Language :: Python :: 3.12
43
+ Classifier: Typing :: Typed
44
+ Requires-Python: >=3.9
45
+ Provides-Extra: docs
46
+ Requires-Dist: furo>=2023.08.17; extra == 'docs'
47
+ Requires-Dist: myst-parser>=0.13; extra == 'docs'
48
+ Requires-Dist: sphinx-autodoc-typehints; extra == 'docs'
49
+ Requires-Dist: sphinx-copybutton; extra == 'docs'
50
+ Requires-Dist: sphinx>=7.0; extra == 'docs'
51
+ Provides-Extra: test
52
+ Requires-Dist: array-api-strict; extra == 'test'
53
+ Requires-Dist: numpy; extra == 'test'
54
+ Requires-Dist: pytest-cov>=3; extra == 'test'
55
+ Requires-Dist: pytest>=6; extra == 'test'
56
+ Description-Content-Type: text/markdown
57
+
58
+ # array-api-extra
59
+
60
+ [![Actions Status][actions-badge]][actions-link]
61
+ [![Documentation Status][rtd-badge]][rtd-link]
62
+ [![Pixi Badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/prefix-dev/pixi/main/assets/badge/v0.json)](https://pixi.sh)
63
+
64
+ [![PyPI version][pypi-version]][pypi-link]
65
+ [![Conda-Forge][conda-badge]][conda-link]
66
+ [![PyPI platforms][pypi-platforms]][pypi-link]
67
+
68
+ <!-- SPHINX-START -->
69
+
70
+ <!-- prettier-ignore-start -->
71
+ [actions-badge]: https://github.com/data-apis/array-api-extra/workflows/CI/badge.svg
72
+ [actions-link]: https://github.com/data-apis/array-api-extra/actions
73
+ [conda-badge]: https://img.shields.io/conda/vn/conda-forge/array-api-extra
74
+ [conda-link]: https://github.com/conda-forge/array-api-extra-feedstock
75
+ [github-discussions-badge]: https://img.shields.io/static/v1?label=Discussions&message=Ask&color=blue&logo=github
76
+ [github-discussions-link]: https://github.com/data-apis/array-api-extra/discussions
77
+ [pypi-link]: https://pypi.org/project/array-api-extra/
78
+ [pypi-platforms]: https://img.shields.io/pypi/pyversions/array-api-extra
79
+ [pypi-version]: https://img.shields.io/pypi/v/array-api-extra
80
+ [rtd-badge]: https://readthedocs.org/projects/array-api-extra/badge/?version=latest
81
+ [rtd-link]: https://array-api-extra.readthedocs.io/en/latest/?badge=latest
82
+
83
+ <!-- prettier-ignore-end -->
84
+
85
+ Extra array functions built on top of the array API standard.
@@ -0,0 +1,8 @@
1
+ array_api_extra/__init__.py,sha256=un-9jpUrfFqisEubFN4BQZJ56cnVEo9uohRopIV3Ooo,131
2
+ array_api_extra/_funcs.py,sha256=n_6jT-_xJ7N0lDtshUFaXscbFKfVdcj42IsMFpjg6RA,1215
3
+ array_api_extra/_typing.py,sha256=-vb0OQATmH1p7pdyJqULXnIG1rKtFPzf3MW_fZ_ypsQ,230
4
+ array_api_extra/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ array_api_extra-0.1.0.dist-info/METADATA,sha256=WtpPfTxAnRyxRVKggIabfLmXD2aHQT9U46bfQfj2X3c,4407
6
+ array_api_extra-0.1.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
7
+ array_api_extra-0.1.0.dist-info/licenses/LICENSE,sha256=WElDmP4Uf9znamiy3s1MCM46HqI3ttZ4UAHBX4IsbtY,1097
8
+ array_api_extra-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.25.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Consortium for Python Data API Standards
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.