Skip to content

cosama/vasapy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vasapy - The spice to your daily dose of numpy

vasapy, short for 'Vectorized ASsociative Arrays for PYthon' is a lightweight wrapper of parallel_hashmap using 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).

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.