Array API Negative Index
Documentation: https://array-api-negative-index.readthedocs.io
Source Code: https://github.com/34j/array-api-negative-index
Utils for indexing arrays with {-n, -(n-1), ..., -1, 0, 1, ..., n-1, n} using array API.
Installation
Install this via pip (or your favourite package manager):
pip install array-api-negative-index
Usage
- This package provides a utility for packing array elements in the order
[0, 1, 2, ..., n, -n, ..., -2, -1]. - This allows one to access the
i-th element byarray[i], regardless of whetheriis positive, 0 or negative, thanks to "Negative Indexing" in array API. - This is useful for representing the order
min spherical harmonics for example.
from array_api_negative_index import to_symmetric, flip_symmetric, arange_asymmetric
arange_asymmetric()
import numpy as np
a = arange_asymmetric(3, xp=np)
print(a)
[ 0 1 2 -2 -1]
Not to confuse with np.arange(-stop + 1, stop)!
This caused me to create bugs many times.
a = np.arange(-2, 3)
print(a)
[-2, -1, 0, 1, 2]
flip_symmetric()
b = flip_symmetric(a)
print(f"{a} -> (flip) -> {b}")
[ 0 1 2 -2 -1] -> (flip) -> [ 0 -1 -2 2 1]
to_symmetric()
c = np.asarray([0, 3, 5])
d = to_symmetric(c, asymmetric=True, conjugate=False)
print(f"{c} -> (to_symmetric) -> {d}")
[0 3 5] -> (to_symmetric) -> [ 0 3 5 -5 -3]
Contributors ✨
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
Credits
This package was created with Copier and the browniebroke/pypackage-template project template.
Metadata
Release files for array-api-negative-index 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| array_api_negative_index-1.0.0.tar.gz | 6.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| array_api_negative_index-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.2 kB
Release files / array_api_negative_index-1.0.0.tar.gz
| Download URL | array_api_negative_index-1.0.0.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e0f3c4a82b4de03b2d63d916fa26351979b34c713708e95b66f1cea7f7862d1a
|
|
BLAKE2b-256 checksum How to use checksums |
2969ebd4846c11deb06e45fb3720f6f4c39be83e8d4a781f89fd3e839782f521
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 23, 2025.
Transparency logRelease files / array_api_negative_index-1.0.0-py3-none-any.whl
| Download URL | array_api_negative_index-1.0.0-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3728ce1d24822a559dbe9a2f68c2131803877d261ce680cbe8e5865860c08f1e
|
|
BLAKE2b-256 checksum How to use checksums |
90f697b52cbcd3fce6d46cc55f3dddc52700d3e1db1ada36d82456a6d59f1649
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 23, 2025.
Transparency log