cognition.decision.chain

Support for a decision process generated via an iterable value.

Classes

Link

A link in a chained decision process

ChainState

State of a chained decision process

Functions

create_chain_dp(chain, link_handler[, init_accumulator])

Decision process via an iterable that with a handler at each value accumulating a result

Module Contents

A link in a chained decision process

value: CV

current iterated value

accumulator: CA | None

current (optional) user-accumulated value

class cognition.decision.chain.ChainState[CV, CA](chain, init_acc=None)

State of a chained decision process

Parameters represent…

  • CV: type of iterated (v)alues

  • CA: type of an optional (a)ccumulator

Parameters:
  • chain (collections.abc.Iterable[CV]) – something iterable

  • init_acc (CA | None) – (optional) initial accumulator value

__str__()
Return type:

str

property done: bool
Returns:

True if the iterable (chain) has been exhausted

Return type:

bool

Returns:

current link in the chain, or None if exhausted

Return type:

Link[CV, CA] | None

property accumulator: CA | None
Returns:

current accumulator value

Return type:

CA | None

next(acc)

Proceeds with the chain

Parameters:

acc (CA | None) – optional new accumulator value

Return type:

None

cognition.decision.chain.create_chain_dp[CV, CA](chain, link_handler, init_accumulator=None)

Decision process via an iterable that with a handler at each value accumulating a result

Parameters:
Returns:

produced decision process

Return type:

cognition.decision.dp.DecisionProcess[ChainState[CV, CA]]