Module to implement C extension Bins class for bin-based storage of items
Project description
Description
binstore module with Bins C extension to implement storage of items based on value-based binning where binned value determines ordinal index into array where item is stored. Supports item assignment and slice operations.
Members
- min - float, minimum value
- max - float, maximum value
- width - float, bin width
- n_bins - int, number of bins = int((max - min) / width) + 1
Methods
- bin(value) - perform binning operation on value and returns corresponding bin ordinal value 0 <= n <= n_bins - 1
- put(value, item) - puts item into bin n = bin(value) and returns n
- get(value) - gets item from bin n = bin(value) and returns as tuple of (item, n)
- items() - returns items in bins as dict with left bin edge as key, item in bin as value
When performing binning:
- if value is <= min, bin(value) = 0
- if value is >= max, bin(value) = n_bins - 1
- if value is >= half the distance between left edge of bin n and left edge of bin n+1, then corresponding bin(value) = n+1, otherwise bin(value) = n. e.g., for min = 0.0, max = 1.0, width = 0.01, bin(0.106) = 11, bin(0.103) = 10.
Example:
>>>b = Bins(min=0.0, max=1.0, width=0.01) >>>for i in range(50): >>> b.put(i/100, {'i': i}) 0 1 2 . 49 >>>b.get(0.005) ({'i': 1}, 1) >>>b.get(0.000) ({'i': 0}, 0) >>>b.get(0.004) ({'i': 0}, 0) >>>b.get(0.103) ({'i': 10}, 10) >>>b.get(0.106) ({'i': 11}, 11) >>>b.put(0.106, {'foo': 'bar'}) 11 >>>b[11] {'foo': 'bar'} >>>b[11] = {'bar': 'foo'} >>>b[11] {'bar': 'foo'}
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file binstore-1.7.1.tar.gz.
File metadata
- Download URL: binstore-1.7.1.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2edca2d76084c28349d3bbe0652b8de5159b6ba36a06dc55865c624cbfad3775
|
|
| MD5 |
400b5b6eae758317780c4e87c27ac2d9
|
|
| BLAKE2b-256 |
af312bf20ad78f05185c5bcdeac592f95cf2794d933103b5f4de2a37ca72cafe
|
File details
Details for the file binstore-1.7.1-cp38-cp38-win_amd64.whl.
File metadata
- Download URL: binstore-1.7.1-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 12.1 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74860d820b50c5b10c8b3372a534950c3d8b7fc541b6631ae4877993c4248c5f
|
|
| MD5 |
d64c4613cdfd52c1efdca842828bd30b
|
|
| BLAKE2b-256 |
50df5483e2efd8f66a441c52aa38175e5b4c61c840b35f949a5d49758ba7362c
|