Numpy Dynamic Array
Dynamically resizing Numpy array.
A dynamic array expands as you add more elements. So you don't need to determine the size ahead of time. The version present here is focused on being compatible with the typical Numpy indexing and functions.
Installation
pip install numpy_dynamic_array
Usage
Basics
from numpy_da import DynamicArray
data = DynamicArray(shape=2)
a = np.linspace(0, 9, 10)
data.append(a) # requires resize (done automatically)
print(data) # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Indexing
Setting values with indexing
data = DynamicArray(shape=2)
data.append(np.linspace(0, 9, 10))
data[3] = 40
print(data) # [0, 1, 2, 3, 40, 5, 6, 7, 8, 9]
Setting values with indexing (outside current array size)
Set index_expansion=True
data = DynamicArray(shape=2, index_expansion=True)
data[5] = 1
print(data) # [0, 0, 0, 0, 0, 1]
Setting values with slices (outside current array size)
Set index_expansion=True
data = DynamicArray(shape=2, index_expansion=True)
data[5:8] = [1, 2, 3]
print(data) # [0, 0, 0, 0, 0, 1, 2, 3]
Operators
Equality:
np_array = np.linspace(0, 9, 10)
data = DynamicArray()
data.append(np_array)
print(all(data == np_array)) # True
Addition:
np_array = np.linspace(0, 9, 10)
data = DynamicArray()
data.append(np_array)
print(all((data + 7.5) == (np_array + 7.5))) # True
Other supported oparators:
- floordiv (//)
- mod (%)
- mul (*)
- neg (-)
- pow (**)
- truediv(/)
- sub (-)
- len (len())
Numpy Functions
np_array = np.linspace(0, 9, 10)
data = DynamicArray()
data.append(np_array)
print(data.max()) # 9
np_array = np.linspace(0, 9, 10)
data = DynamicArray()
data.append(np_array)
print(np.abs(data - 5)) # [5. 4. 3. 2. 1. 0. 1. 2. 3. 4.]
Multidimensional arrays
Use the shape to specify initial ndarray with correct dimensions.
data = DynamicArray(shape=(2, 2)) # requires resize
a = np.linspace(0, 9, 10).reshape(5, 2)
data.append(a)
For more examples look at the tests folder.
Metadata
Release files for numpy-dynamic-array 0.0.1
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 |
|---|---|---|---|---|
| numpy_dynamic_array-0.0.1.tar.gz | 5.6 kB | Without provenance | Details for numpy_dynamic_array-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| numpy_dynamic_array-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for numpy_dynamic_array-0.0.1-py3-none-any.whl |
Total release size: 11.0 kB
Release files / numpy_dynamic_array-0.0.1.tar.gz
| Download URL | numpy_dynamic_array-0.0.1.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aa98bc8909055765a4803334af659f9d3ca81a4c88743830edb1620759d8ae10
|
|
BLAKE2b-256 checksum How to use checksums |
7de7a4cb1f1bbaacbccd3524c6b166ce11a953ac3c2e6fd9918d829b0883ebb0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
|
Release files / numpy_dynamic_array-0.0.1-py3-none-any.whl
| Download URL | numpy_dynamic_array-0.0.1-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c878f973f5850c727e4cab9e7ae5baa2a4cffd3993fe1b8b3e1c613ab89256ae
|
|
BLAKE2b-256 checksum How to use checksums |
ab9caaf8be5ea70c571cbe1630cb4d43e6df31a91c49e10d69f342f810b433f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
|
Security for numpy-dynamic-array 0.0.1
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.