Factor Groups

class authorityspoke.groups.ComparableGroup(value: Sequence = ())

Factors to be used together in a comparison.

The inputs, outputs, and despite Factors of a Procedure should be FactorGroups.

consistent_with(other, context=None)

Find whether two sets of Factors can be consistent.

Works by first determining whether one Factor potentially contradicts() another, and then determining whether it’s possible to make context assignments match between the contradictory Factors.

Parameters
  • other (Optional[Comparable]) –

  • context (Optional[ContextRegister]) – correspondences between :class:`Factor`s in self and other that can’t be changed in seeking a way to interpret the groups as consistent

Return type

bool

Returns

whether unassigned context factors can be assigned in such a way that there’s no contradiction between any factor in self_factors and other_factors, given that some Factors have already been assigned as described by matches.

contradicts(other, context=None)

Find whether two sets of Factors can be contradictory.

Parameters
  • other (ComparableGroup) – a second set of Factors with context factors that are internally consistent, but may not be consistent with self_factors.

  • context (Optional[ContextRegister]) – correspondences between :class:`Factor`s in self and other that can’t be changed in seeking a contradiction

Return type

bool

Returns

whether any Factor assignment can be found that makes a Factor in the output of other contradict a Factor in the output of self.

comparison(operation, still_need_matches, matches=None)

Find ways for two unordered sets of Factors to satisfy a comparison.

All of the elements of other need to fit the comparison. The elements of self don’t all need to be used.

Parameters
  • context – a mapping of Factors that have already been matched to each other in the recursive search for a complete group of matches. Usually starts empty when the method is first called.

  • still_need_matches (Sequence[Factor]) – Factors that need to satisfy the comparison comparison with some Factor of available for the relation to hold, and have not yet been matched.

  • matches (Optional[ContextRegister]) – a ContextRegister matching generic Factors

Yields

context registers showing how each Factor in need_matches can have the relation comparison with some Factor in available_for_matching, with matching context.

Return type

Iterator[ContextRegister]

get_factor_by_name(name)

Search of self and self’s attributes for Factor with specified name.

Return type

Factor

Returns

a Factor with the specified name attribute if it exists, otherwise None.

get_factor_by_str(query)

Search of self and self’s attributes for Factor with specified string.

Return type

Optional[Factor]

Returns

a Factor with the specified string if it exists, otherwise None.

verbose_comparison(operation, still_need_matches, explanation=None)

Find ways for two unordered sets of Factors to satisfy a comparison.

All of the elements of other need to fit the comparison. The elements of self don’t all need to be used.

Parameters
  • context – a mapping of Factors that have already been matched to each other in the recursive search for a complete group of matches. Usually starts empty when the method is first called.

  • still_need_matches (Sequence[Factor]) – Factors that need to satisfy the comparison comparison with some Factor of available for the relation to hold, and have not yet been matched.

  • explanation (Optional[Explanation]) – an Explanation showing which Factors listed in the FactorGroups were matched to each other, and also including a ContextRegister.

Yields

context registers showing how each Factor in need_matches can have the relation comparison with some Factor in available_for_matching, with matching context.

Return type

Iterator[Explanation]

explanations_implication(other, context=None)

Generate ContextRegisters that cause self to imply other.

If self is absent, then generate a ContextRegister from other’s point of view and then swap the keys and values.

Return type

Iterator[Explanation]

property generic_factors_by_name

Factors that can be replaced without changing selfs meaning.

Return type

Dict[str, Comparable]

Returns

a list made from a dict with self’s generic Factors as keys and None as values, so that the keys can be matched to another object’s generic_factors to perform an equality test.

drop_implied_factors()

Reduce group by removing redundant members implied by other members.

Return type

ComparableGroup

Returns

new group with any redundant items remomved

internally_consistent(context=None)

Check for contradictions among the Factors in self.

Return type

bool

Returns

bool indicating whether self is internally consistent

new_context(changes)

Create new Comparable, replacing keys of changes with values.

Parameters

changes (ContextRegister) – has Comparables to replace as keys, and has their replacements as the corresponding values.

Return type

ComparableGroup

Returns

a new Comparable object with the replacements made.