Memory mapped of datasets
Project description
Memmpy
Memmpy is a Python library for storing datasets in, and loading datasets from, memory mapped files. This is particularly useful for large datasets that do not fit in memory and therefore need to be processed in batches. Memmpy is based on the numpy.memmap
implementation.
Who should use Memmpy?
Memmpy is primarily intended for use in medium to large scale machine learning applications in high energy particle physics, where the whole dataset would not fit into memory at once and iterating over the ROOT files is too slow. This could be because shuffling of datapoints is desired, or because only a fraction of the information or events is needed for training.
Memmpy is not intended for use in small applications where the entire dataset fits into memory and can be loaded at once. It is also not intended for use in very large applications where training is massively distributed.
Installation
Memmpy can be installed directly from PyPI using pip
. It requires Python 3.10 or higher.
If you want to process .root
files, uproot
is required. This can also be installed using pip
.
pip install memmpy
Usage
A simple memory mapped file can be created as follows:
with WriteVector(path="data.mmpy", name="testdata") as memfile:
# Append a single numpy array.
# The shape and dtype will be inferred from the array.
memfile.append(np.array([1, 2, 3]))
# Append another numpy array of the same shape and dtype
memfile.append(np.array([4, 5, 6]))
# Extend the file by an array with an additional axis.
memfile.extend(np.array([[7, 8, 9], [10, 11, 12]]))
memmap_data = read_vector(path="data.mmpy", name="testdata")
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 memmpy-0.1.6.tar.gz
.
File metadata
- Download URL: memmpy-0.1.6.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d36cfa526524079dac61e46525a6840957c657070c2bbd100a9bbf6e789735a |
|
MD5 | eccc567b89c5f24842cf36351729c666 |
|
BLAKE2b-256 | 90ca9dd6832192e5b4c84e143f9741128bc22e2eefb922512982f6ef418050d4 |
File details
Details for the file memmpy-0.1.6-py3-none-any.whl
.
File metadata
- Download URL: memmpy-0.1.6-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 363f71d9ecf216ea4c4c9774d54a43ceefec236a833b6a1fe415bc0845ccaaed |
|
MD5 | 821750825eb5b280320cca5ed848926f |
|
BLAKE2b-256 | 8eadc24f4adddd685fc6914b44533e03a244791d76e3951344d522c793d36108 |