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 hashes)