---------------------------------------------------------------------- This is the API documentation for the spector library. ---------------------------------------------------------------------- ## Classes indices A sparse boolean array, i.e., set of indices. Provides a memory efficient set interface, with optimized conversion between numpy arrays. Args: keys (Iterable): optional iterable of keys vector A sparse array of index keys mapped to numeric values. Provides a memory efficient Counter interface, with optimized conversion between numpy arrays. Args: keys (Iterable[int]): optional iterable of keys values: optional scalar or iterable of values matrix(data=(), copy=True) A sparse vector of vectors. Args: data (Iterable): ## Functions groupby(keys: collections.abc.Iterable, *arrays) -> collections.abc.Iterator[tuple] Generate unique keys with associated groups. Args: keys: *arrays (Iterable): ---------------------------------------------------------------------- This is the User Guide documentation for the package. ---------------------------------------------------------------------- ## indices ```{python} import numpy as np from spector import indices ind = indices([0, 2]) ind ``` ```{python} np.array(ind) ``` ```{python} 1 in ind ``` ```{python} ind.add(1) ``` ```{python} ind.todense() ``` ```{python} indices.fromdense([True, False, True]) ``` ## vector ```{python} from spector import vector vec = vector({0: 1.0, 2: 2.0, 4: 1.0}) vec ``` ```{python} np.array(vec) ``` ```{python} vec[2] += 1.0 vec[2] ``` ```{python} vec.sum() ``` ```{python} vec.todense() ``` ```{python} vector.fromdense([1, 0, 2, 0, 1]) ``` ## matrix ```{python} from spector import matrix mat = matrix({0: {1: 2.0}}) mat ``` ```{python} mat.row, mat.col, mat.data ```