sparse bit array
Project description
Sparse Bit Array
A sparse bit array stores the indices of the bits that are ON. Made in cython.
Overview
>>> from sba import * >>> z = SBA.iterable([0, 3, 40]) # an SBA with the bits at index 0, 3, and 40 set to ON >>> z [0, 3, 40] >>> z.set(3, False) >>> z [0 40] >>> y = SBA.iterable([0, 3, 40, 50]) >>> z & y # overloaded ops [0 40] >>> z.andl(y) # The number of ON bits shared between z AND y 2 >>> y.to_np() # numpy ndarray conversion array([ 0, 3, 50], dtype=int32) >>> memoryview(y)[0] # implements buffer protocol 0 >>> # Randomly flips bits OFF, where each bit has a 33% chance of remaining ON >>> SBA.length(6) * (1 / 3) [2 5] >>> # encodes a float value by turning 3 bits ON in an array with a total size of 100 >>> SBA.encode(0.0, 3, 100) [0 1 2] >>> SBA.encode(0.5, 3, 100) [49 50 51] >>> SBA.encode(1.0, 3, 100) [97 98 99]
Installation: PyPI
pip install sparse-bit-array
Installation: GitHub
git clone https://github.com/jagprog5/sba.git
cd sba
Install repo to system:
python setup.py install
Install repo to directory and run tests:
python setup.py build_ext --inplace python tests.py
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
sparse-bit-array-1.1.2.tar.gz
(206.3 kB
view hashes)
Built Distribution
Close
Hashes for sparse_bit_array-1.1.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d31050a62c653045c52078c8a2645f0e9a185fb26ab00a3b17f820d0159b9620 |
|
MD5 | 98624e9f0780561f408b0af46c7c8275 |
|
BLAKE2-256 | 374256fa988574cdfdfb40b864baa1aba2472f1fbfe2af533bfa660567c84d37 |