id_translation.mapping.types#

Types used for mapping.

Module Attributes

HL

Hashable type on the left side of a directional relationship.

HR

Hashable type on the right side of a directional relationship.

LeftToRight

A left-to-right mapping.

RightToLeft

A right-to-left mapping.

ValueType

A type of item being mapped.

CandidateType

A type of item being mapped.

MatchTuple

A tuple of candidates matched to a value.

ContextType

Type of context in which mapping is being performed.

UserOverrideFunction

Signature for a user-defined override function.

ScoreFunction

Signature for a likeness score function.

AliasFunction

Signature for an alias function for heuristic scoring.

FilterFunction

Signature for a filter function.

HeuristicsTypes

Types that may be interpreted as a score function heuristic.

OnUnmapped

Action types for unmapped values.

OnUnknownUserOverride

Action types for bad user overrides (dict or function).

AliasFunction#

Signature for an alias function for heuristic scoring.

Parameters:
  • value – An element to find matches for.

  • candidates – Potential matches for value.

  • context – The context in which mapping is being performed.

Keyword Arguments:

kwargs – Accepted only by some functions.

Returns:

A tuple (name, candidates) with applied heuristics to increase (or decrease) score as desired.

alias of Callable[[ValueType, Iterable[CandidateType], ContextType | None], tuple[ValueType, Iterable[CandidateType]]]

class CandidateType#

A type of item being mapped.

alias of TypeVar(‘CandidateType’, bound=Hashable)

class ContextType#

Type of context in which mapping is being performed.

alias of TypeVar(‘ContextType’, bound=Hashable)

FilterFunction#

Signature for a filter function.

Parameters:
  • value – An element to find matches for.

  • candidates – Potential matches for value.

  • context – The context in which filtering is being performed.

Keyword Arguments:

kwargs – Accepted only by some functions.

Returns:

A subset of candidates to keep.

alias of Callable[[ValueType, Iterable[CandidateType], ContextType | None], set[CandidateType]]

class HL#

Hashable type on the left side of a directional relationship.

alias of TypeVar(‘HL’, bound=Hashable)

class HR#

Hashable type on the right side of a directional relationship.

alias of TypeVar(‘HR’, bound=Hashable)

HeuristicsTypes = collections.abc.Callable[[~ValueType, collections.abc.Iterable[~CandidateType], ~ContextType | None], tuple[~ValueType, collections.abc.Iterable[~CandidateType]]] | collections.abc.Callable[[~ValueType, collections.abc.Iterable[~CandidateType], ~ContextType | None], set[~CandidateType]]#

Types that may be interpreted as a score function heuristic.

LeftToRight#

A left-to-right mapping.

alias of dict[HL, tuple[HR, …]]

MatchTuple#

A tuple of candidates matched to a value.

alias of tuple[CandidateType, …]

OnUnknownUserOverride#

Action types for bad user overrides (dict or function).

alias of Literal[‘raise’, ‘warn’, ‘keep’]

OnUnmapped#

Action types for unmapped values.

alias of Literal[‘raise’, ‘warn’, ‘ignore’]

RightToLeft#

A right-to-left mapping.

alias of dict[HR, tuple[HL, …]]

ScoreFunction#

Signature for a likeness score function.

Parameters:
  • value – An element to find matches for.

  • candidates – Potential matches for value.

  • context – The context in which scoring is being performed.

Keyword Arguments:

kwargs – Accepted only by some functions.

Yields:

A score for each candidate c in candidates.

alias of Callable[[ValueType, Iterable[CandidateType], ContextType | None], Iterable[float]]

UserOverrideFunction#

Signature for a user-defined override function.

Parameters:
  • value – An element to find matches for.

  • candidates – Potential matches for value.

  • context – The context in which scoring is being performed.

Returns:

Either None (let regular logic decide) or a single candidate c in candidates.

alias of Callable[[ValueType, set[CandidateType], ContextType | None], CandidateType | None]

class ValueType#

A type of item being mapped.

alias of TypeVar(‘ValueType’, bound=Hashable)