Utils for indexing arrays with {-n, -(n-1), ..., -1, 0, 1, ..., n-1, n} using array API.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file array_api_negative_index-1.0.0.tar.gz.
File metadata
- Download URL: array_api_negative_index-1.0.0.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0f3c4a82b4de03b2d63d916fa26351979b34c713708e95b66f1cea7f7862d1a
|
|
| MD5 |
143d8fe4ec017549c4e104be8e5e0ab5
|
|
| BLAKE2b-256 |
2969ebd4846c11deb06e45fb3720f6f4c39be83e8d4a781f89fd3e839782f521
|
Provenance
The following attestation bundles were made for array_api_negative_index-1.0.0.tar.gz:
Publisher:
ci.yml on 34j/array-api-negative-index
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
array_api_negative_index-1.0.0.tar.gz -
Subject digest:
e0f3c4a82b4de03b2d63d916fa26351979b34c713708e95b66f1cea7f7862d1a - Sigstore transparency entry: 425188064
- Sigstore integration time:
-
Permalink:
34j/array-api-negative-index@67cfab58c672c9b37b37a4a6c48373675b495a19 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/34j
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@67cfab58c672c9b37b37a4a6c48373675b495a19 -
Trigger Event:
push
-
Statement type:
File details
Details for the file array_api_negative_index-1.0.0-py3-none-any.whl.
File metadata
- Download URL: array_api_negative_index-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3728ce1d24822a559dbe9a2f68c2131803877d261ce680cbe8e5865860c08f1e
|
|
| MD5 |
a3366e75890285cb724a01cd8a3e9091
|
|
| BLAKE2b-256 |
90f697b52cbcd3fce6d46cc55f3dddc52700d3e1db1ada36d82456a6d59f1649
|
Provenance
The following attestation bundles were made for array_api_negative_index-1.0.0-py3-none-any.whl:
Publisher:
ci.yml on 34j/array-api-negative-index
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
array_api_negative_index-1.0.0-py3-none-any.whl -
Subject digest:
3728ce1d24822a559dbe9a2f68c2131803877d261ce680cbe8e5865860c08f1e - Sigstore transparency entry: 425188072
- Sigstore integration time:
-
Permalink:
34j/array-api-negative-index@67cfab58c672c9b37b37a4a6c48373675b495a19 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/34j
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@67cfab58c672c9b37b37a4a6c48373675b495a19 -
Trigger Event:
push
-
Statement type: