DynamicSizeRecarray
A dynamic, appandable version of Numpy’s recarray. The goal is to have a recarray-like-object which can be appended to in a transparent and efficient way.
install
pip install dynamicsizerecarray
basic use
Initialize an empty DynamicSizeRecarray with a dtype.
import dynamicsizerecarray
dra = dynamicsizerecarray.DynamicSizeRecarray(
dtype=[("hour", "u1"), ("minute", "u1"), ("temperature", "f8")]
)
len(dra)
0
Or initialize the DynamicSizeRecarray with an already existing recarray.
import numpy
rec = numpy.recarray(
shape=1,
dtype=[("hour", "u1"), ("minute", "u1"), ("temperature", "f8")],
)
rec["hour"][0] = 2
rec["minute"][0] = 13
rec["temperature"][0] = 20.123
dra = dynamicsizerecarray.DynamicSizeRecarray(recarray=rec)
len(dra)
1
After initializing, the DynamicSizeRecarray can be appended to dynamically. You can append a record, i.e. a dict.
dra.append_record({"hour": 3, "minute": 53, "temperature": 22.434})
len(dra)
2
Or you can append another recarray.
rec = numpy.recarray(
shape=1,
dtype=[("hour", "u1"), ("minute", "u1"), ("temperature", "f8")],
)
rec["hour"][0] = 13
rec["minute"][0] = 41
rec["temperature"][0] = 18.623
dra.append_recarray(rec)
len(dra)
3
When the dynamic appending is done, the DynamicSizeRecarray can be exported to a classic, and static recarray.
final = dra.to_recarray()
Further the DynamicSizeRecarray provides the properties shape and dtype, and also implements __gettitem__, __setitem__.
dra.shape # shape
(3, )
dra[0] # __gettitem__
(2, 13, 20.123)
dra[1] = (7, 25, 21.45) # __setitem__
len(dra) # __len__
3
dra.dtype # exposes the internal recarray's dtype
dtype((numpy.record, [('hour', 'u1'), ('minute', 'u1'), ('temperature', '<f8')]))
wording
record is a dict with keys (and values) matching the dtype of the DynamicSizeRecarray. (Wording is adopted from pandas).
records is just a list of record s (Also adopted from pandas).
recarray is short for np.recarray.
Metadata
Release files for dynamicsizerecarray 0.1.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 | Provenance | Actions |
|---|---|---|---|---|
| dynamicsizerecarray-0.1.0.tar.gz | 5.6 kB | Without provenance | Details for dynamicsizerecarray-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dynamicsizerecarray-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for dynamicsizerecarray-0.1.0-py3-none-any.whl |
Total release size: 11.4 kB
Release files / dynamicsizerecarray-0.1.0.tar.gz
| Download URL | dynamicsizerecarray-0.1.0.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
993b517da5245d02ea0b342ad521263b51220865e3f15629ec430c18816f28cd
|
|
BLAKE2b-256 checksum How to use checksums |
25c69bc37baf4b27f238b1a43dade06ae2ef0b23b1fc3c35e002590de4d4512f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.5
|
Release files / dynamicsizerecarray-0.1.0-py3-none-any.whl
| Download URL | dynamicsizerecarray-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c84c99f9372766bc9a9d782c79229c3dfbe852df6b494a2e9713c75062dbbe5d
|
|
BLAKE2b-256 checksum How to use checksums |
15be145b91065ed5779c0006a7b84805e08499b833bbe8f1e89a4577e4356d18
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.5
|
Security for dynamicsizerecarray 0.1.0
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.