array-api-negative-index 0.1.0__tar.gz → 1.1.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.
- {array_api_negative_index-0.1.0/src/array_api_negative_index.egg-info → array_api_negative_index-1.1.0}/PKG-INFO +12 -35
- {array_api_negative_index-0.1.0 → array_api_negative_index-1.1.0}/README.md +5 -27
- array_api_negative_index-1.1.0/pyproject.toml +56 -0
- {array_api_negative_index-0.1.0 → array_api_negative_index-1.1.0}/src/array_api_negative_index/__init__.py +1 -1
- {array_api_negative_index-0.1.0 → array_api_negative_index-1.1.0}/src/array_api_negative_index/_main.py +15 -19
- {array_api_negative_index-0.1.0 → array_api_negative_index-1.1.0/src/array_api_negative_index.egg-info}/PKG-INFO +12 -35
- {array_api_negative_index-0.1.0 → array_api_negative_index-1.1.0}/src/array_api_negative_index.egg-info/SOURCES.txt +0 -1
- {array_api_negative_index-0.1.0 → array_api_negative_index-1.1.0}/tests/test_main.py +7 -4
- array_api_negative_index-0.1.0/pyproject.toml +0 -164
- array_api_negative_index-0.1.0/setup.py +0 -9
- {array_api_negative_index-0.1.0 → array_api_negative_index-1.1.0}/LICENSE +0 -0
- {array_api_negative_index-0.1.0 → array_api_negative_index-1.1.0}/setup.cfg +0 -0
- {array_api_negative_index-0.1.0 → array_api_negative_index-1.1.0}/src/array_api_negative_index/py.typed +0 -0
- {array_api_negative_index-0.1.0 → array_api_negative_index-1.1.0}/src/array_api_negative_index.egg-info/dependency_links.txt +0 -0
- {array_api_negative_index-0.1.0 → array_api_negative_index-1.1.0}/src/array_api_negative_index.egg-info/requires.txt +0 -0
- {array_api_negative_index-0.1.0 → array_api_negative_index-1.1.0}/src/array_api_negative_index.egg-info/top_level.txt +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: array-api-negative-index
|
|
3
|
-
Version:
|
|
4
|
-
Summary: Utils for indexing arrays with {-n, -(n-1)
|
|
5
|
-
Author
|
|
6
|
-
License: MIT
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: Utils for indexing arrays with {-n, -(n-1),..., -1, 0, 1,..., n-1, n} using array API.
|
|
5
|
+
Author: 34j
|
|
6
|
+
License-Expression: MIT
|
|
7
7
|
Project-URL: Bug Tracker, https://github.com/34j/array-api-negative-index/issues
|
|
8
8
|
Project-URL: Changelog, https://github.com/34j/array-api-negative-index/blob/main/CHANGELOG.md
|
|
9
9
|
Project-URL: documentation, https://array-api-negative-index.readthedocs.io
|
|
@@ -12,13 +12,12 @@ Classifier: Development Status :: 2 - Pre-Alpha
|
|
|
12
12
|
Classifier: Intended Audience :: Developers
|
|
13
13
|
Classifier: Natural Language :: English
|
|
14
14
|
Classifier: Operating System :: OS Independent
|
|
15
|
-
Classifier: Programming Language :: Python :: 3
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
17
|
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
19
|
Classifier: Topic :: Software Development :: Libraries
|
|
21
|
-
Requires-Python: >=3.
|
|
20
|
+
Requires-Python: >=3.12
|
|
22
21
|
Description-Content-Type: text/markdown
|
|
23
22
|
License-File: LICENSE
|
|
24
23
|
Requires-Dist: array-api-compat>=1.11.2
|
|
@@ -34,19 +33,19 @@ Dynamic: license-file
|
|
|
34
33
|
<a href="https://array-api-negative-index.readthedocs.io">
|
|
35
34
|
<img src="https://img.shields.io/readthedocs/array-api-negative-index.svg?logo=read-the-docs&logoColor=fff&style=flat-square" alt="Documentation Status">
|
|
36
35
|
</a>
|
|
37
|
-
<a href="https://codecov.io/gh/34j/array-api-negative-index">
|
|
38
|
-
<img src="https://img.shields.io/codecov/c/github/34j/array-api-negative-index.svg?logo=codecov&logoColor=fff&style=flat-square" alt="Test coverage percentage">
|
|
39
|
-
</a>
|
|
40
36
|
</p>
|
|
41
37
|
<p align="center">
|
|
38
|
+
<a href="https://codecov.io/gh/34j/array-api-jit">
|
|
39
|
+
<img src="https://img.shields.io/codecov/c/github/34j/array-api-negative-index.svg?logo=codecov&logoColor=fff&style=flat-square" alt="Test coverage percentage">
|
|
40
|
+
</a>
|
|
42
41
|
<a href="https://github.com/astral-sh/uv">
|
|
43
42
|
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json" alt="uv">
|
|
44
43
|
</a>
|
|
45
44
|
<a href="https://github.com/astral-sh/ruff">
|
|
46
45
|
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff">
|
|
47
46
|
</a>
|
|
48
|
-
<a href="https://github.com/
|
|
49
|
-
<img src="https://img.shields.io/
|
|
47
|
+
<a href="https://github.com/j178/prek">
|
|
48
|
+
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/j178/prek/master/docs/assets/badge-v0.json" alt="prek">
|
|
50
49
|
</a>
|
|
51
50
|
</p>
|
|
52
51
|
<p align="center">
|
|
@@ -132,25 +131,3 @@ print(f"{c} -> (to_symmetric) -> {d}")
|
|
|
132
131
|
```text
|
|
133
132
|
[0 3 5] -> (to_symmetric) -> [ 0 3 5 -5 -3]
|
|
134
133
|
```
|
|
135
|
-
|
|
136
|
-
## Contributors ✨
|
|
137
|
-
|
|
138
|
-
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
139
|
-
|
|
140
|
-
<!-- prettier-ignore-start -->
|
|
141
|
-
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
142
|
-
<!-- markdownlint-disable -->
|
|
143
|
-
<!-- markdownlint-enable -->
|
|
144
|
-
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
145
|
-
<!-- prettier-ignore-end -->
|
|
146
|
-
|
|
147
|
-
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
|
148
|
-
|
|
149
|
-
## Credits
|
|
150
|
-
|
|
151
|
-
[](https://github.com/copier-org/copier)
|
|
152
|
-
|
|
153
|
-
This package was created with
|
|
154
|
-
[Copier](https://copier.readthedocs.io/) and the
|
|
155
|
-
[browniebroke/pypackage-template](https://github.com/browniebroke/pypackage-template)
|
|
156
|
-
project template.
|
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
<a href="https://array-api-negative-index.readthedocs.io">
|
|
8
8
|
<img src="https://img.shields.io/readthedocs/array-api-negative-index.svg?logo=read-the-docs&logoColor=fff&style=flat-square" alt="Documentation Status">
|
|
9
9
|
</a>
|
|
10
|
-
<a href="https://codecov.io/gh/34j/array-api-negative-index">
|
|
11
|
-
<img src="https://img.shields.io/codecov/c/github/34j/array-api-negative-index.svg?logo=codecov&logoColor=fff&style=flat-square" alt="Test coverage percentage">
|
|
12
|
-
</a>
|
|
13
10
|
</p>
|
|
14
11
|
<p align="center">
|
|
12
|
+
<a href="https://codecov.io/gh/34j/array-api-jit">
|
|
13
|
+
<img src="https://img.shields.io/codecov/c/github/34j/array-api-negative-index.svg?logo=codecov&logoColor=fff&style=flat-square" alt="Test coverage percentage">
|
|
14
|
+
</a>
|
|
15
15
|
<a href="https://github.com/astral-sh/uv">
|
|
16
16
|
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json" alt="uv">
|
|
17
17
|
</a>
|
|
18
18
|
<a href="https://github.com/astral-sh/ruff">
|
|
19
19
|
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff">
|
|
20
20
|
</a>
|
|
21
|
-
<a href="https://github.com/
|
|
22
|
-
<img src="https://img.shields.io/
|
|
21
|
+
<a href="https://github.com/j178/prek">
|
|
22
|
+
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/j178/prek/master/docs/assets/badge-v0.json" alt="prek">
|
|
23
23
|
</a>
|
|
24
24
|
</p>
|
|
25
25
|
<p align="center">
|
|
@@ -105,25 +105,3 @@ print(f"{c} -> (to_symmetric) -> {d}")
|
|
|
105
105
|
```text
|
|
106
106
|
[0 3 5] -> (to_symmetric) -> [ 0 3 5 -5 -3]
|
|
107
107
|
```
|
|
108
|
-
|
|
109
|
-
## Contributors ✨
|
|
110
|
-
|
|
111
|
-
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
112
|
-
|
|
113
|
-
<!-- prettier-ignore-start -->
|
|
114
|
-
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
115
|
-
<!-- markdownlint-disable -->
|
|
116
|
-
<!-- markdownlint-enable -->
|
|
117
|
-
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
118
|
-
<!-- prettier-ignore-end -->
|
|
119
|
-
|
|
120
|
-
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
|
121
|
-
|
|
122
|
-
## Credits
|
|
123
|
-
|
|
124
|
-
[](https://github.com/copier-org/copier)
|
|
125
|
-
|
|
126
|
-
This package was created with
|
|
127
|
-
[Copier](https://copier.readthedocs.io/) and the
|
|
128
|
-
[browniebroke/pypackage-template](https://github.com/browniebroke/pypackage-template)
|
|
129
|
-
project template.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
build-backend = "setuptools.build_meta"
|
|
3
|
+
requires = [ "setuptools>=77.0.3" ]
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "array-api-negative-index"
|
|
7
|
+
version = "1.1.0"
|
|
8
|
+
description = "Utils for indexing arrays with {-n, -(n-1),..., -1, 0, 1,..., n-1, n} using array API."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "34j" },
|
|
13
|
+
]
|
|
14
|
+
requires-python = ">=3.12"
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Natural Language :: English",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Programming Language :: Python :: 3.14",
|
|
24
|
+
"Topic :: Software Development :: Libraries",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"array-api-compat>=1.11.2",
|
|
28
|
+
"types-array-api>=1.1.4",
|
|
29
|
+
]
|
|
30
|
+
urls."Bug Tracker" = "https://github.com/34j/array-api-negative-index/issues"
|
|
31
|
+
urls.Changelog = "https://github.com/34j/array-api-negative-index/blob/main/CHANGELOG.md"
|
|
32
|
+
urls.documentation = "https://array-api-negative-index.readthedocs.io"
|
|
33
|
+
urls.repository = "https://github.com/34j/array-api-negative-index"
|
|
34
|
+
|
|
35
|
+
[dependency-groups]
|
|
36
|
+
dev = [
|
|
37
|
+
"coverage",
|
|
38
|
+
"numpy>=2.0.2",
|
|
39
|
+
"packaging-34j[test]>=1.1.8",
|
|
40
|
+
"pytest>=9",
|
|
41
|
+
"pytest-cov>=7",
|
|
42
|
+
"torch>=2.8",
|
|
43
|
+
"ty>=0.0.10",
|
|
44
|
+
]
|
|
45
|
+
docs = [
|
|
46
|
+
"packaging-34j[docs]>=1.1.8",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[tool.ruff]
|
|
50
|
+
extend = ".venv/ruff.toml"
|
|
51
|
+
|
|
52
|
+
[tool.pyproject-fmt]
|
|
53
|
+
max_supported_python = "3.14"
|
|
54
|
+
|
|
55
|
+
[tool.ty]
|
|
56
|
+
terminal.error-on-warning = true
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
from typing import Any
|
|
1
|
+
from typing import Any, cast
|
|
2
2
|
|
|
3
3
|
from array_api._2024_12 import Array, ArrayNamespaceFull
|
|
4
4
|
from array_api_compat import array_namespace
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
def to_symmetric(
|
|
8
|
-
input: Array,
|
|
8
|
+
input: Array, # noqa: A002
|
|
9
9
|
/,
|
|
10
10
|
*,
|
|
11
11
|
axis: int = 0,
|
|
@@ -30,22 +30,17 @@ def to_symmetric(
|
|
|
30
30
|
-------
|
|
31
31
|
Array
|
|
32
32
|
The symmetric tensor.
|
|
33
|
-
|
|
34
|
-
forall a < input.shape[axis] result[-a] = result[a]
|
|
35
|
-
Else,
|
|
36
|
-
forall a < input.shape[axis] result[-a-1] = result[a]
|
|
33
|
+
Forall a < input.shape[axis], result[-a] = result[a].
|
|
37
34
|
|
|
38
35
|
"""
|
|
39
|
-
xp = array_namespace(input)
|
|
36
|
+
xp = array_namespace(cast("Any", input))
|
|
40
37
|
input_to_symmetric = input
|
|
41
38
|
if asymmetric:
|
|
42
39
|
input_to_symmetric = -input_to_symmetric
|
|
43
40
|
if conjugate:
|
|
44
41
|
input_to_symmetric = xp.conj(input_to_symmetric)
|
|
45
|
-
axis
|
|
46
|
-
input_to_symmetric = input_to_symmetric[
|
|
47
|
-
(slice(None),) * axis + (slice(1, None), ...)
|
|
48
|
-
]
|
|
42
|
+
axis %= input.ndim
|
|
43
|
+
input_to_symmetric = input_to_symmetric[(slice(None),) * axis + (slice(1, None), ...)]
|
|
49
44
|
input_to_symmetric = xp.flip(input_to_symmetric, axis=axis)
|
|
50
45
|
return xp.concat([input, input_to_symmetric], axis=axis)
|
|
51
46
|
|
|
@@ -79,13 +74,16 @@ def arange_asymmetric(
|
|
|
79
74
|
The shape is (2 * stop - 1,).
|
|
80
75
|
|
|
81
76
|
"""
|
|
82
|
-
return
|
|
83
|
-
|
|
84
|
-
|
|
77
|
+
return cast(
|
|
78
|
+
"Array",
|
|
79
|
+
to_symmetric(
|
|
80
|
+
xp.arange(stop, dtype=dtype, device=device),
|
|
81
|
+
asymmetric=True,
|
|
82
|
+
),
|
|
85
83
|
)
|
|
86
84
|
|
|
87
85
|
|
|
88
|
-
def flip_symmetric(input: Array, /, *, axis: int = 0) -> Array:
|
|
86
|
+
def flip_symmetric(input: Array, /, *, axis: int = 0) -> Array: # noqa: A002
|
|
89
87
|
"""
|
|
90
88
|
Flip a symmetric array.
|
|
91
89
|
|
|
@@ -95,8 +93,6 @@ def flip_symmetric(input: Array, /, *, axis: int = 0) -> Array:
|
|
|
95
93
|
The input array.
|
|
96
94
|
axis : int, optional
|
|
97
95
|
The axis to flip, by default 0
|
|
98
|
-
include_zero_twice : bool, optional
|
|
99
|
-
If True, the zeroth element is included twice, by default False
|
|
100
96
|
|
|
101
97
|
Returns
|
|
102
98
|
-------
|
|
@@ -105,8 +101,8 @@ def flip_symmetric(input: Array, /, *, axis: int = 0) -> Array:
|
|
|
105
101
|
Forall a < input.shape[axis] result[-a-1] = result[a] = input[a] = input[-a-1]
|
|
106
102
|
|
|
107
103
|
"""
|
|
108
|
-
xp = array_namespace(input)
|
|
109
|
-
axis
|
|
104
|
+
xp = array_namespace(cast("Any", input))
|
|
105
|
+
axis %= input.ndim
|
|
110
106
|
zero = input[
|
|
111
107
|
(
|
|
112
108
|
slice(
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: array-api-negative-index
|
|
3
|
-
Version:
|
|
4
|
-
Summary: Utils for indexing arrays with {-n, -(n-1)
|
|
5
|
-
Author
|
|
6
|
-
License: MIT
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: Utils for indexing arrays with {-n, -(n-1),..., -1, 0, 1,..., n-1, n} using array API.
|
|
5
|
+
Author: 34j
|
|
6
|
+
License-Expression: MIT
|
|
7
7
|
Project-URL: Bug Tracker, https://github.com/34j/array-api-negative-index/issues
|
|
8
8
|
Project-URL: Changelog, https://github.com/34j/array-api-negative-index/blob/main/CHANGELOG.md
|
|
9
9
|
Project-URL: documentation, https://array-api-negative-index.readthedocs.io
|
|
@@ -12,13 +12,12 @@ Classifier: Development Status :: 2 - Pre-Alpha
|
|
|
12
12
|
Classifier: Intended Audience :: Developers
|
|
13
13
|
Classifier: Natural Language :: English
|
|
14
14
|
Classifier: Operating System :: OS Independent
|
|
15
|
-
Classifier: Programming Language :: Python :: 3
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
17
|
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
19
|
Classifier: Topic :: Software Development :: Libraries
|
|
21
|
-
Requires-Python: >=3.
|
|
20
|
+
Requires-Python: >=3.12
|
|
22
21
|
Description-Content-Type: text/markdown
|
|
23
22
|
License-File: LICENSE
|
|
24
23
|
Requires-Dist: array-api-compat>=1.11.2
|
|
@@ -34,19 +33,19 @@ Dynamic: license-file
|
|
|
34
33
|
<a href="https://array-api-negative-index.readthedocs.io">
|
|
35
34
|
<img src="https://img.shields.io/readthedocs/array-api-negative-index.svg?logo=read-the-docs&logoColor=fff&style=flat-square" alt="Documentation Status">
|
|
36
35
|
</a>
|
|
37
|
-
<a href="https://codecov.io/gh/34j/array-api-negative-index">
|
|
38
|
-
<img src="https://img.shields.io/codecov/c/github/34j/array-api-negative-index.svg?logo=codecov&logoColor=fff&style=flat-square" alt="Test coverage percentage">
|
|
39
|
-
</a>
|
|
40
36
|
</p>
|
|
41
37
|
<p align="center">
|
|
38
|
+
<a href="https://codecov.io/gh/34j/array-api-jit">
|
|
39
|
+
<img src="https://img.shields.io/codecov/c/github/34j/array-api-negative-index.svg?logo=codecov&logoColor=fff&style=flat-square" alt="Test coverage percentage">
|
|
40
|
+
</a>
|
|
42
41
|
<a href="https://github.com/astral-sh/uv">
|
|
43
42
|
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json" alt="uv">
|
|
44
43
|
</a>
|
|
45
44
|
<a href="https://github.com/astral-sh/ruff">
|
|
46
45
|
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff">
|
|
47
46
|
</a>
|
|
48
|
-
<a href="https://github.com/
|
|
49
|
-
<img src="https://img.shields.io/
|
|
47
|
+
<a href="https://github.com/j178/prek">
|
|
48
|
+
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/j178/prek/master/docs/assets/badge-v0.json" alt="prek">
|
|
50
49
|
</a>
|
|
51
50
|
</p>
|
|
52
51
|
<p align="center">
|
|
@@ -132,25 +131,3 @@ print(f"{c} -> (to_symmetric) -> {d}")
|
|
|
132
131
|
```text
|
|
133
132
|
[0 3 5] -> (to_symmetric) -> [ 0 3 5 -5 -3]
|
|
134
133
|
```
|
|
135
|
-
|
|
136
|
-
## Contributors ✨
|
|
137
|
-
|
|
138
|
-
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
139
|
-
|
|
140
|
-
<!-- prettier-ignore-start -->
|
|
141
|
-
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
142
|
-
<!-- markdownlint-disable -->
|
|
143
|
-
<!-- markdownlint-enable -->
|
|
144
|
-
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
145
|
-
<!-- prettier-ignore-end -->
|
|
146
|
-
|
|
147
|
-
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
|
148
|
-
|
|
149
|
-
## Credits
|
|
150
|
-
|
|
151
|
-
[](https://github.com/copier-org/copier)
|
|
152
|
-
|
|
153
|
-
This package was created with
|
|
154
|
-
[Copier](https://copier.readthedocs.io/) and the
|
|
155
|
-
[browniebroke/pypackage-template](https://github.com/browniebroke/pypackage-template)
|
|
156
|
-
project template.
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
from array_api._2024_12 import ArrayNamespaceFull
|
|
3
3
|
|
|
4
|
-
from array_api_negative_index import flip_symmetric, to_symmetric
|
|
4
|
+
from array_api_negative_index import arange_asymmetric, flip_symmetric, to_symmetric
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def test_arange_asymmetric(xp: ArrayNamespaceFull) -> None:
|
|
8
|
+
result = arange_asymmetric(3, xp=xp)
|
|
9
|
+
assert xp.all(result == xp.asarray([0, 1, 2, -2, -1]))
|
|
5
10
|
|
|
6
11
|
|
|
7
12
|
def test_flip_symmetric(xp: ArrayNamespaceFull) -> None:
|
|
@@ -12,9 +17,7 @@ def test_flip_symmetric(xp: ArrayNamespaceFull) -> None:
|
|
|
12
17
|
|
|
13
18
|
@pytest.mark.parametrize("asymmetric", [True, False])
|
|
14
19
|
@pytest.mark.parametrize("conjugate", [True, False])
|
|
15
|
-
def test_to_symmetric_manual(
|
|
16
|
-
asymmetric: bool, conjugate: bool, xp: ArrayNamespaceFull
|
|
17
|
-
) -> None:
|
|
20
|
+
def test_to_symmetric_manual(asymmetric: bool, conjugate: bool, xp: ArrayNamespaceFull) -> None:
|
|
18
21
|
array = xp.asarray([0, 1 + 1j, 2 - 1j])
|
|
19
22
|
result = to_symmetric(xp.asarray(array), asymmetric=asymmetric, conjugate=conjugate)
|
|
20
23
|
if asymmetric and conjugate:
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
build-backend = "setuptools.build_meta"
|
|
3
|
-
requires = [ "setuptools" ]
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "array-api-negative-index"
|
|
7
|
-
version = "0.1.0"
|
|
8
|
-
description = "Utils for indexing arrays with {-n, -(n-1), ..., -1, 0, 1, ..., n-1, n} using array API."
|
|
9
|
-
readme = "README.md"
|
|
10
|
-
license = { text = "MIT" }
|
|
11
|
-
authors = [
|
|
12
|
-
{ name = "34j", email = "34j.95a2p@simplelogin.com" },
|
|
13
|
-
]
|
|
14
|
-
requires-python = ">=3.9"
|
|
15
|
-
classifiers = [
|
|
16
|
-
"Development Status :: 2 - Pre-Alpha",
|
|
17
|
-
"Intended Audience :: Developers",
|
|
18
|
-
"Natural Language :: English",
|
|
19
|
-
"Operating System :: OS Independent",
|
|
20
|
-
"Programming Language :: Python :: 3.9",
|
|
21
|
-
"Programming Language :: Python :: 3.10",
|
|
22
|
-
"Programming Language :: Python :: 3.11",
|
|
23
|
-
"Programming Language :: Python :: 3.12",
|
|
24
|
-
"Programming Language :: Python :: 3.13",
|
|
25
|
-
"Topic :: Software Development :: Libraries",
|
|
26
|
-
]
|
|
27
|
-
|
|
28
|
-
dependencies = [
|
|
29
|
-
"array-api-compat>=1.11.2",
|
|
30
|
-
"types-array-api>=1.1.4",
|
|
31
|
-
]
|
|
32
|
-
urls."Bug Tracker" = "https://github.com/34j/array-api-negative-index/issues"
|
|
33
|
-
urls.Changelog = "https://github.com/34j/array-api-negative-index/blob/main/CHANGELOG.md"
|
|
34
|
-
urls.documentation = "https://array-api-negative-index.readthedocs.io"
|
|
35
|
-
urls.repository = "https://github.com/34j/array-api-negative-index"
|
|
36
|
-
|
|
37
|
-
[dependency-groups]
|
|
38
|
-
dev = [
|
|
39
|
-
"numpy>=2.0.2",
|
|
40
|
-
"pytest>=8,<9",
|
|
41
|
-
"pytest-cov>=6,<7",
|
|
42
|
-
"torch>=2.8.0",
|
|
43
|
-
]
|
|
44
|
-
docs = [
|
|
45
|
-
"furo>=2023.5.20; python_version>='3.11'",
|
|
46
|
-
"myst-parser>=0.16; python_version>='3.11'",
|
|
47
|
-
"sphinx>=4; python_version>='3.11'",
|
|
48
|
-
"sphinx-autobuild>=2024,<2025; python_version>='3.11'",
|
|
49
|
-
]
|
|
50
|
-
|
|
51
|
-
[tool.ruff]
|
|
52
|
-
line-length = 88
|
|
53
|
-
lint.select = [
|
|
54
|
-
"B", # flake8-bugbear
|
|
55
|
-
"D", # flake8-docstrings
|
|
56
|
-
"C4", # flake8-comprehensions
|
|
57
|
-
"S", # flake8-bandit
|
|
58
|
-
"F", # pyflake
|
|
59
|
-
"E", # pycodestyle
|
|
60
|
-
"W", # pycodestyle
|
|
61
|
-
"UP", # pyupgrade
|
|
62
|
-
"I", # isort
|
|
63
|
-
"RUF", # ruff specific
|
|
64
|
-
]
|
|
65
|
-
lint.ignore = [
|
|
66
|
-
"D203", # 1 blank line required before class docstring
|
|
67
|
-
"D212", # Multi-line docstring summary should start at the first line
|
|
68
|
-
"D100", # Missing docstring in public module
|
|
69
|
-
"D104", # Missing docstring in public package
|
|
70
|
-
"D107", # Missing docstring in `__init__`
|
|
71
|
-
"D401", # First line of docstring should be in imperative mood
|
|
72
|
-
]
|
|
73
|
-
lint.per-file-ignores."conftest.py" = [ "D100" ]
|
|
74
|
-
lint.per-file-ignores."docs/conf.py" = [ "D100" ]
|
|
75
|
-
lint.per-file-ignores."setup.py" = [ "D100" ]
|
|
76
|
-
lint.per-file-ignores."tests/**/*" = [
|
|
77
|
-
"D100",
|
|
78
|
-
"D101",
|
|
79
|
-
"D102",
|
|
80
|
-
"D103",
|
|
81
|
-
"D104",
|
|
82
|
-
"S101",
|
|
83
|
-
]
|
|
84
|
-
lint.isort.known-first-party = [ "array_api_negative_index", "tests" ]
|
|
85
|
-
|
|
86
|
-
[tool.pytest.ini_options]
|
|
87
|
-
addopts = """\
|
|
88
|
-
-v
|
|
89
|
-
-Wdefault
|
|
90
|
-
--cov=array_api_negative_index
|
|
91
|
-
--cov-report=term
|
|
92
|
-
--cov-report=xml
|
|
93
|
-
"""
|
|
94
|
-
pythonpath = [ "src" ]
|
|
95
|
-
|
|
96
|
-
[tool.coverage.run]
|
|
97
|
-
branch = true
|
|
98
|
-
|
|
99
|
-
[tool.coverage.report]
|
|
100
|
-
exclude_lines = [
|
|
101
|
-
"pragma: no cover",
|
|
102
|
-
"@overload",
|
|
103
|
-
"if TYPE_CHECKING",
|
|
104
|
-
"raise NotImplementedError",
|
|
105
|
-
'if __name__ == "__main__":',
|
|
106
|
-
]
|
|
107
|
-
|
|
108
|
-
[tool.mypy]
|
|
109
|
-
check_untyped_defs = true
|
|
110
|
-
disallow_any_generics = true
|
|
111
|
-
disallow_incomplete_defs = true
|
|
112
|
-
disallow_untyped_defs = true
|
|
113
|
-
mypy_path = "src/"
|
|
114
|
-
no_implicit_optional = true
|
|
115
|
-
show_error_codes = true
|
|
116
|
-
warn_unreachable = true
|
|
117
|
-
warn_unused_ignores = true
|
|
118
|
-
exclude = [
|
|
119
|
-
'docs/.*',
|
|
120
|
-
'setup.py',
|
|
121
|
-
]
|
|
122
|
-
|
|
123
|
-
[[tool.mypy.overrides]]
|
|
124
|
-
module = "tests.*"
|
|
125
|
-
allow_untyped_defs = true
|
|
126
|
-
|
|
127
|
-
[[tool.mypy.overrides]]
|
|
128
|
-
module = "docs.*"
|
|
129
|
-
ignore_errors = true
|
|
130
|
-
|
|
131
|
-
[tool.semantic_release]
|
|
132
|
-
version_toml = [ "pyproject.toml:project.version" ]
|
|
133
|
-
version_variables = [
|
|
134
|
-
"src/array_api_negative_index/__init__.py:__version__",
|
|
135
|
-
"docs/conf.py:release",
|
|
136
|
-
]
|
|
137
|
-
build_command = """
|
|
138
|
-
pip install uv
|
|
139
|
-
uv lock
|
|
140
|
-
git add uv.lock
|
|
141
|
-
uv build
|
|
142
|
-
"""
|
|
143
|
-
|
|
144
|
-
[tool.semantic_release.changelog]
|
|
145
|
-
exclude_commit_patterns = [
|
|
146
|
-
'''chore(?:\([^)]*?\))?: .+''',
|
|
147
|
-
'''ci(?:\([^)]*?\))?: .+''',
|
|
148
|
-
'''refactor(?:\([^)]*?\))?: .+''',
|
|
149
|
-
'''style(?:\([^)]*?\))?: .+''',
|
|
150
|
-
'''test(?:\([^)]*?\))?: .+''',
|
|
151
|
-
'''build\((?!deps\): .+)''',
|
|
152
|
-
'''Merged? .*''',
|
|
153
|
-
'''Initial [Cc]ommit.*''', # codespell:ignore
|
|
154
|
-
]
|
|
155
|
-
|
|
156
|
-
[tool.semantic_release.changelog.environment]
|
|
157
|
-
keep_trailing_newline = true
|
|
158
|
-
|
|
159
|
-
[tool.semantic_release.branches.main]
|
|
160
|
-
match = "main"
|
|
161
|
-
|
|
162
|
-
[tool.semantic_release.branches.noop]
|
|
163
|
-
match = "(?!main$)"
|
|
164
|
-
prerelease = true
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|