bool to int8 serialization with ray.io
Project description
bool-to-int8-ray
bool to int8 serialization with ray.io
Installation
pip install bool-to-int8-ray
Usage
export B2I8_PCT_CPU=0.6
from bool_to_int8_ray import bool_to_int8_batch, int8_to_bool_batch
import numpy as np
# given lists of binary hashes
hashvalues = np.array([
[1, 0, 1, 0, 1, 1, 0, 0],
[1, 1, 0, 0, 0, 0, 0, 1]
])
# convert to list of int8 values
serialized = bool_to_int8_batch(hashvalues)
# convert back
deserialized = int8_to_bool_batch(serialized)
Speed Test
source .venv/bin/activate
export B2I8_PCT_CPU=0.6
python test/speedtest.py
Results
4.776991 -- numpy version, hash to int8
6.031101 -- numpy version, int8 to hash
2.308446 -- ray.io version, hash to int8
3.023865 -- ray.io version, int8 to hash
Appendix
Installation
The bool-to-int8-ray
git repo is available as PyPi package
pip install bool-to-int8-ray
pip install git+ssh://git@github.com/ulf1/bool-to-int8-ray.git
Install a virtual environment
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt --no-cache-dir
pip install -r requirements-dev.txt --no-cache-dir
(If your git repo is stored in a folder with whitespaces, then don't use the subfolder .venv
. Use an absolute path without whitespaces.)
Python commands
- Jupyter for the examples:
jupyter lab
- Check syntax:
flake8 --ignore=F401 --exclude=$(grep -v '^#' .gitignore | xargs | sed -e 's/ /,/g')
- Run Unit Tests:
PYTHONPATH=. pytest
- Run Speed Test:
python test/speedtest.py
Publish
# pandoc README.md --from markdown --to rst -s -o README.rst
python setup.py sdist
twine upload -r pypi dist/*
Clean up
find . -type f -name "*.pyc" | xargs rm
find . -type d -name "__pycache__" | xargs rm -r
rm -r .pytest_cache
rm -r .venv
Support
Please open an issue for support.
Contributing
Please contribute using Github Flow. Create a branch, add commits, and open a pull request.
Acknowledgements
The "Evidence" project was funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) - 433249742 (GU 798/27-1; GE 1119/11-1).
Maintenance
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
File details
Details for the file bool-to-int8-ray-0.2.0.tar.gz
.
File metadata
- Download URL: bool-to-int8-ray-0.2.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.9.6 requests/2.31.0 setuptools/59.6.0 requests-toolbelt/1.0.0 tqdm/4.65.0 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bbbc4e4fe45cfd066f06040c6fc2cd8ebaa2546170b2c843827a0c7d3f40dbb |
|
MD5 | 6abd17e39620d22256428f8c3ef0498f |
|
BLAKE2b-256 | 9a8e87d82d5937fa1c808f904e5ee0079dfe478a926b47bea22521459aea8e7a |