Python bi-dimensional matrix iterator starting from any point (x, y) iterating layer by layer around some starting coordinates.
Project description
Circular iterator (Citerate)
Python bi-dimensional matrix iterator starting from any point (x, y) iterating layer by layer around some starting coordinates.
Usage
pip install citerate
As of 14 july 2021 it contains one method citerator
from citerate import citerator
Examples
Using the example data set:
DATA = [
[10, 11, 12, 13, 14],
[25, 2, 3, 4, 15],
[24, 9, 1, 5, 16],
[23, 8, 7, 6, 17],
[22, 21, 20, 19, 18],
]
Iterate over the set layer by layer starting from coordinates (x=2, y=2) and print each layer as a list of it's corresponding values.
for layer in citerator(DATA, x=2, y=2, layer=True):
print(layer)
Yields:
[1]
[2, 3, 4, 5, 6, 7, 8, 9]
[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
Iterate over the set value by value starting from coordinates (x=2, y=2) and print each value individually.
for value in citerator(DATA, x=2, y=2):
print(value, end=' ')
Yields:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Footnotes
- It is NOT mandatory to iterate starting from the central coordinates or for the matrix to be uniform.
- It HAS to be bi-dimenstional and follow a "list of lists" pattern.
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
File details
Details for the file citerate-0.1.1.tar.gz
.
File metadata
- Download URL: citerate-0.1.1.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2287d2c28eb7b05e0fb04364b42ec972d084f92d92947ba9a263224c7d92ccb4 |
|
MD5 | e2c89bde83a48d11362dfa5b18f33e17 |
|
BLAKE2b-256 | 090c03a7dce1298f4f3a24e099c0326e34d7275aeae6c81589743ba445e52a27 |
File details
Details for the file citerate-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: citerate-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 247b54e04cd4447629dc36c921bf953b8e4cf3fb5c545d6e92a10a396f0f7119 |
|
MD5 | 1490ac3b4e541187736da1a636d4ba4c |
|
BLAKE2b-256 | 059cd0d78e53f7f9dcb25a7d6bfc78086672e27d13543c700c39ea0775b21957 |