yarrow.segmented.finite_function

Finite coproducts for Finite Functions. They’re used to parallelize several operations like the yarrow.functor.functor.Functor.map_objects() method.

class yarrow.segmented.finite_function.AbstractIndexedCoproduct(sources: AbstractFiniteFunction, values: AbstractFiniteFunction)

A finite coproduct of finite functions. You can think of it simply as a segmented array. Categorically, it represents a finite coproduct:

Σ_{i ∈ N} f_i : s(f_i) → Y

as a pair of maps:

sources: N            → Nat     (target is natural numbers)
values : sum(sources) → Σ₀
sources: AbstractFiniteFunction
values: AbstractFiniteFunction
property target
classmethod from_list(target, fs: List[AbstractFiniteFunction])

Create an AbstractIndexedCoproduct from a list of AbstractFiniteFunction

map(x: AbstractFiniteFunction)

Given an AbstractIndexedCoproduct of finite functions:

Σ_{i ∈ X} f_i : Σ_{i ∈ X} A_i → B

and a finite function:

x : W → X

return a new AbstractIndexedCoproduct representing:

Σ_{i ∈ X} f_{x(i)} : Σ_{i ∈ W} A_{x(i)} → B
coproduct(x: AbstractFiniteFunction) AbstractFiniteFunction

Like map but only computes the values array of an AbstractIndexedCoproduct

class yarrow.segmented.finite_function.AbstractSegmentedFiniteFunction(sources: AbstractFiniteFunction, targets: AbstractFiniteFunction, values: AbstractFiniteFunction)

An AbstractSegmentedFiniteFunction encodes a tensoring of finite functions. This means we have to include an array of targets as well.

..warning::

Deprecated

sources: AbstractFiniteFunction
targets: AbstractFiniteFunction
values: AbstractFiniteFunction
classmethod from_list(fs: List[AbstractFiniteFunction])

Create a SegmentedFiniteFunction from a list of morphisms

property N
slice(x: AbstractFiniteFunction)
coproduct(x: AbstractFiniteFunction)

sff.coproduct(x) computes an x-indexed coproduct of sff

tensor(x: AbstractFiniteFunction)

sff.coproduct(x) computes an x-indexed tensor product of sff