Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cosama/vasapy
Vectorized Associative Arrays for Python
https://github.com/cosama/vasapy
associative-array associative-map dictionary numpy python vectorized
Last synced: about 2 months ago
JSON representation
Vectorized Associative Arrays for Python
- Host: GitHub
- URL: https://github.com/cosama/vasapy
- Owner: cosama
- License: apache-2.0
- Created: 2020-07-27T20:33:14.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-17T23:01:19.000Z (over 4 years ago)
- Last Synced: 2024-11-14T09:35:59.693Z (2 months ago)
- Topics: associative-array, associative-map, dictionary, numpy, python, vectorized
- Language: Python
- Homepage:
- Size: 47.9 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
vasapy - The spice to your daily dose of numpy
=================================================vasapy, short for 'Vectorized ASsociative Arrays for PYthon' is a lightweight wrapper of [parallel_hashmap](https://github.com/greg7mdp/parallel-hashmap.git)
using [pybind11](https://github.com/pybind/pybind11) to allow for vectorized
operation on dictionaries (and maybe later sets).The dictionary behave like the python default dictionary with most methods
implemented, but additionally all methods can also use numpy arrays, doing
the iterations over array elements internally in C++ way more efficiently. It
supports most of the numpy types (128/256 byte types are not tested and might
behave unexpectedly).```python
import vasapy as vp
import numpy as npkeys = np.arange(100)
data = np.random.rand(100)*100
ind = np.arange(10)# create a dictionary from arrays
d = vp.dict(keys, data)# key access with array or integer
print(d[ind])
print(d[0])# setting elements with arrays or integer
d[ind] = np.zeros(len(ind))
d[101] = 0# accessing elements with default value
ind = np.arange(0, 200)
print(d.get(ind, 0))
```## Installation
The package is available on pip.
```
pip install vasapy --user
```If it doesn't build try to install pybind11 `pip install pybind11 --user` and
install the python development files with your package manager.