Kronecker
A small library that provides a convenient syntax for creating boolean tensors / sparse matrices.
Examples
i, j = kronecker.indices(4, 4)
arr = (i >= j * 2 - 1).to_numpy()
np.array_equal(arr, np.array([
[1, 0, 0, 0],
[1, 1, 0, 0],
[1, 1, 0, 0],
[1, 1, 1, 0]
]).astype(bool))
> True
i, j, k = kronecker.indices(2, 2, 3)
arr = (i >= j + k - 1).to_numpy()
np.array_equal(arr, np.array([
[[1, 1, 0], [1, 0, 0]],
[[1, 1, 1], [1, 1, 0]]
]).astype(bool))
> True
# would run out of memory if created as a numpy array
i, j = kronecker.indices(1_000_000, 1_000_000)
x = (i * 5 == j).to_sparse()
assert x.sum() == 200000
Limitations
- When creating sparse matrices linear expressions in the indices are simplified and evaluated once per row, giving a complexity of O(n_rows * n_True_per_row). For non-linear expressions (including ones that contain integer division
//) a slower, O(n_rows * n_cols), path is used. This is mostly useless, creating a numpy array and converting is much faster (but uses more memory). - Only the operators {
+,-,*,/,//,**} are supported. - Multiple comparisons (
i < j < 2 * i) are not supported.
Metadata
Release files for kronecker 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kronecker-0.0.2.tar.gz | 8.6 kB | Without provenance | Details for kronecker-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kronecker-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for kronecker-0.0.2-py3-none-any.whl |
Total release size: 18.3 kB
Release files / kronecker-0.0.2.tar.gz
| Download URL | kronecker-0.0.2.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8aa98394669ce4658388c4e3a85e6f3d1e181149c63d351a450eedcc8f053461
|
|
BLAKE2b-256 checksum How to use checksums |
66b35f0477489b7e61b174ff80d6c51188c09f72e8bb196297113813343e481e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Release files / kronecker-0.0.2-py3-none-any.whl
| Download URL | kronecker-0.0.2-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3b163319b25488c98682068f3a4fa1bf29c13cc133337279f41fe11dbe3241a9
|
|
BLAKE2b-256 checksum How to use checksums |
d81f417a34aeeab580e313047306d6246848dc467ba4c39d1911331b3c04594c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Security for kronecker 0.0.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.