Comparisons

class authorityspoke.comparisons.Comparable
property short_string

Return string representation without line breaks.

Return type

str

consistent_with(other, context=None)

Check if self and other can be non-contradictory.

Return type

bool

Returns

a bool indicating whether there’s at least one way to match the context_factors of self and other, such that they fit the relationship comparison.

contradicts(other, context=None)

Test whether self implies the absence of other.

Return type

bool

Returns

True if self and other can’t both be true at the same time. Otherwise returns False.

property context_factors

Get Factors used in comparisons with other Factors.

Return type

FactorSequence

Returns

a tuple of attributes that are designated as the context_factors for whichever subclass of Factor calls this method. These can be used for comparing objects using consistent_with()

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.

get_factor_by_name(name)

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

Return type

Optional[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.

property interchangeable_factors

List ways to reorder context_factors but preserve self’s meaning.

The empty list is the default return value for subclasses that don’t have any interchangeable context_factors.

Return type

List[ContextRegister]

Returns

the ways context_factors can be reordered without changing the meaning of self, or whether it would be true in a particular context.

implied_by(other, context=None)

Test whether other implies self.

implies(other, context=None)

Test whether self implies other.

Return type

bool

__gt__(other)

Test whether self implies other and self != other.

Return type

bool

means(other, context=None)

Test whether self and other have identical meanings.

Return type

bool

Returns

whether other is another Factor with the same meaning as self. Not the same as an equality comparison with the == symbol, which simply converts self’s and other’s fields to tuples and compares them.

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

Comparable

Returns

a new Comparable object with the replacements made.

own_attributes()

Return attributes of self that aren’t inherited from another class.

Used for getting parameters to pass to __init__() when generating a new object.

Return type

Dict[str, Any]

possible_contexts(other, context=None)

Get permutations of generic Factor assignments not ruled out by the known context.

Parameters

other (Comparable) – another Comparable object with generic Factors

Yields

all possible ContextRegisters linking the two Comparables

Return type

Iterator[ContextRegister]

property recursive_factors

Collect self’s context_factors, and their context_factors, recursively.

Return type

Dict[str, Comparable]

Returns

a dict (instead of a set, to preserve order) of Factors.

update_context_register(other, context, comparison)

Find ways to update self_mapping to allow relationship comparison.

Parameters
Yields

every way that self_mapping can be updated to be consistent with self and other having the relationship comparison.

Return type

Iterator[ContextRegister]

__ge__(other)

Call implies() as an alias.

Return type

bool

Returns

bool indicating whether self implies other

explain_same_meaning(other, context=None)

Get one explanation of why self and other have the same meaning.

Return type

Optional[ContextRegister]

explain_consistent_with(other, context=None)

Get one explanation of why self and other need not contradict.

Return type

Optional[ContextRegister]

explain_contradiction(other, context=None)

Get one explanation of why self and other contradict.

Return type

Optional[ContextRegister]

explain_implication(other, context=None)

Get one explanation of why self implies other.

Return type

Optional[ContextRegister]

explain_implied_by(other, context=None)

Get one explanation of why self implies other.

Return type

Optional[ContextRegister]

explanations_contradiction(other, context=None)

Test whether self implies() the absence of other.

This should only be called after confirming that other is not None.

Return type

Iterator[ContextRegister]

Returns

True if self and other can’t both be true at the same time. Otherwise returns False.

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[ContextRegister]

__weakref__

list of weak references to the object (if defined)

Explanations

class authorityspoke.explanations.Explanation(matches, context=None, operation=<built-in function ge>)
operation(b, /)

Same as a >= b.

property reason

Make statement matching analagous context factors of self and other.

Return type

str

__str__()

Return str(self).

__weakref__

list of weak references to the object (if defined)