Reference

indices

class spector.indices

A sparse boolean array, i.e., set of indices.

Provides a memory efficient set interface, with optimized conversion between numpy arrays.

Parameters:keys – optional iterable of keys
__and__

Return self&value.

__array__()

Return keys as numpy array.

__contains__

Return key in self.

__eq__

Return self==value.

__ge__

Return self>=value.

__gt__

Return self>value.

__iand__

Return self&=value.

__init__

Initialize self. See help(type(self)) for accurate signature.

__ior__

Return self|=value.

__isub__

Return self-=value.

__iter__

Implement iter(self).

__ixor__

Return self^=value.

__le__

Return self<=value.

__len__

Return len(self).

__lt__

Return self<value.

__matmul__

Return binary dot product, i.e., intersection count.

__ne__

Return self!=value.

__new__()

Create and return a new object. See help(type) for accurate signature.

__or__

Return self|value.

__rand__

Return value&self.

__repr__

Return repr(self).

__rmatmul__

Return value@self.

__ror__

Return value|self.

__rsub__

Return value-self.

__rxor__

Return value^self.

__sub__

Return self-value.

__xor__

Return self^value.

add()

Add an index key.

clear()

Remove all indices.

difference()

Return the difference of sets as a new set.

discard()

Remove an index key, if present.

dot()

Return the intersection count of sets.

fromdense()

Return indices from a dense array representation.

intersection()

Return the intersection of sets as a new set.

isdisjoint()

Return whether two indices have a null intersection.

todense()

Return a dense array representation of indices.

union()

Return the union of sets as a new set.

update()

Update from indices, arrays, or iterables.

vector

class spector.vector

A sparse array of index keys mapped to numeric values.

Provides a memory efficient Counter interface, with optimized conversion between numpy arrays.

Parameters:
  • keys – optional iterable of keys
  • values – optional scalar or iterable of values
__abs__

abs(self)

__add__

Return self+value.

__and__

Return self&value.

__array__()

Return values as numpy array.

__contains__

Return key in self.

__delitem__

Delete self[key].

__eq__

Return self==value.

__ge__

Return self>=value.

__getitem__

Return self[key].

__gt__

Return self>value.

__iadd__

Return self+=value.

__iand__

Return self&=value.

__imul__

Return self*=value.

__init__

Initialize self. See help(type(self)) for accurate signature.

__ior__

Return self|=value.

__ipow__

Return self**=value.

__isub__

Return self-=value.

__iter__

Implement iter(self).

__itruediv__

Return self/=value.

__ixor__

Return self^=value.

__le__

Return self<=value.

__len__

Return len(self).

__lt__

Return self<value.

__matmul__

Return vector dot product.

__mul__

Return self*value.

__ne__

Return self!=value.

__neg__

-self

__new__()

Create and return a new object. See help(type) for accurate signature.

__or__

Return self|value.

__pow__

Return pow(self, value, mod).

__radd__

Return value+self.

__rand__

Return value&self.

__repr__

Return repr(self).

__rmatmul__

Return value@self.

__rmul__

Return value*self.

__ror__

Return value|self.

__rpow__

Return pow(value, self, mod).

__rsub__

Return value-self.

__rtruediv__

Return value/self.

__rxor__

Return value^self.

__setitem__

Set self[key] to value.

__sub__

Return self-value.

__truediv__

Return self/value.

__xor__

Return self^value.

argmax()

Return key with maximum value.

argmin()

Return key with minimum value.

argpartition()

Return keys partitioned by values.

argsort()

Return keys sorted by values.

clear()

Remove all items.

difference()

Provisional set difference; return vector without keys.

equal()

Return whether vectors are equal as scalar bool; == is element-wise.

filter()

Return element-wise array of keys from applying predicate across vectors.

fromdense()

Return vector from a dense array representation.

items()

Return zipped keys and values.

keys()

Return keys as numpy array.

map()

Return element-wise array of values from applying function across vectors.

max()

Return maximum value.

maximum()

Return element-wise maximum vector.

min()

Return minimum value.

minimum()

Return element-wise minimum vector.

sum()

Return sum of values.

todense()

Return a dense array representation of vector.

update()

Update from vector, arrays, mapping, or keys with scalar.

values()

Return values as numpy array.

matrix

class spector.matrix(data=(), copy=True)[source]

Bases: collections.defaultdict

A sparse vector of vectors.

__add__(other) → spector.matrix.matrix[source]
__mul__(other) → dict[source]
__matmul__(other: spector.matrix.matrix) → spector.matrix.matrix[source]
T

Return matrix with reversed dimensions.

col

COO format column index array of the matrix

data

COO format data array of the matrix

filter(func: Callable, *args, **kwargs) → spector.matrix.matrix[source]

Return matrix with function applies across vectors.

classmethod fromcoo(row: Iterable[T_co], col: Iterable[int], data: Iterable[float]) → spector.matrix.matrix[source]

Return matrix from COOrdinate format arrays.

map(func: Callable, *args, **kwargs) → dict[source]

Return matrix with function applies across vectors.

row

COO format row index array of the matrix

sum(axis: int = None)[source]

Return sum of matrix elements across axis, by default both.

transpose() → spector.matrix.matrix[source]

Return matrix with reversed dimensions.

update(data)[source]

Update from mapping or iterable.

groupby

spector.groupby(keys: Iterable[T_co], *arrays) → Iterator[tuple][source]

Generate unique keys with associated groups.