yarrow.array.numpy
numpy- and scipy-backed arrays and algorithms. Almost all exposed functions are thin wrappers around numpy functions. The only exceptions are:
connected_components()
– wraps scipy.sparse.csgraph.connected_componentssegmented_arange()
– a subroutine implemented in terms of the other primitives
This module is the default array backend.
It’s used by FiniteFunction
.
- yarrow.array.numpy.Type
The underlying array type used by functions in the backend. For numpy this is
np.ndarray
.
- yarrow.array.numpy.array(*args, **kwargs)
- yarrow.array.numpy.max(*args, **kwargs)
- yarrow.array.numpy.arange(*args, **kwargs)
- yarrow.array.numpy.all(*args, **kwargs)
- yarrow.array.numpy.zeros(*args, **kwargs)
- yarrow.array.numpy.ones(*args, **kwargs)
- yarrow.array.numpy.cumsum(*args, **kwargs)
- yarrow.array.numpy.sum(*args, **kwargs)
- yarrow.array.numpy.repeat(*args, **kwargs)
- yarrow.array.numpy.concatenate(*args, **kwargs)
- yarrow.array.numpy.connected_components(source, target, n, dtype='int64')
Compute the connected components of a graph with
N
nodes, whose edges are encoded as a pair of arrays(source, target)
such that the edges of the graph aresource[i] → target[i]
.- Parameters:
source (array) – A length-N array with elements in the set
{0 .. N - 1}
.target (array) – A length-N array with elements in the set
{0 .. N - 1}
.
- Returns:
A pair
(c, cc_ix)
of the number of connected componentsc
and a mapping from nodes to connected componentscc_ix
.- Return type:
(int, array)
- yarrow.array.numpy.argsort(x)
- yarrow.array.numpy.segmented_arange(x)
Given an array of sizes,
[x₀, x₁, ...]
output an array equal to the concatenationconcatenate([arange(x₀), arange(x₁), ...])
>>> FiniteFunction._Array.segmented_arange([5, 2, 3, 1]) array([0, 1, 2, 3, 4, 0, 1, 0, 1, 2, 0])
- Params:
x: An array of the sizes of each “segment” of the output
- Returns:
segmented array with segment
i
equal toarange(i)
.- Return type:
array
- yarrow.array.numpy.bincount(x, *args, **kwargs)
- yarrow.array.numpy.full(n, x, *args, **kwargs)