NumPy File
Project description
npyfile is a a package that allows you to continuously write arrays to a .npy file. You can use it like a standard Python file with the well-known context manager.
Warning: Due to the internal structure of .npy files, the arrays must have the same shape & dtype.
Example
Generate some artificial dummy data, e.g. images, & write them into a temporary file. A real world scenario reflecting this is the continuous arrival of new images from a camera.
import pathlib
import tempfile
tmp_dir = tempfile.TemporaryDirectory()
outfile = pathlib.Path(tmp_dir.name) / 'images.npy'
images = np.random.randint(low=0, high=255, size=(10,640,480,3))
with NpyFile(outfile) as file:
for img in images:
file.write(img)
np.testing.assert_array_equal(images, np.load(outfile))
tmp_dir.cleanup()
Credits
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
npyfile-1.0.0.tar.gz
(10.5 kB
view details)
Built Distribution
File details
Details for the file npyfile-1.0.0.tar.gz
.
File metadata
- Download URL: npyfile-1.0.0.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.1.3 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25658f37448d3522710765d3e7afcecef81da747dde3b1562274648debc74ba3 |
|
MD5 | 2d11cd9f0a834d627d28014c089ec38b |
|
BLAKE2b-256 | c271d23e95e4ee394f5ef3c66f8362c1f05690dc43e9a12c16bd4f0eaa5c5d9f |
File details
Details for the file npyfile-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: npyfile-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.1.3 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10f7abcea1ec0d77edc3344be2c9fc2e01214b9cdf85f8ca3c450c3c02bc30f7 |
|
MD5 | 4fd94d53d7cdd89fdbf7af73f84add75 |
|
BLAKE2b-256 | 53f355680764f046a5f3ce4c13e8cf4f5dd963c4ef2a2bf16426d50d456f6931 |