Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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 np

keys = 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.