rics.translation.types#

Types used for translation.

Module Attributes

Translatable

Enumeration of translatable types.

ID

Name of the ID placeholder.

NameType

Type used to label collections of IDs, such as the column names in a DataFrame or the keys of a dict.

IdType

Type of the value being translated into human-readable labels.

SourceType

Type used to describe sources.

ExtendedOverrideFunction

Signature for a user-defined override function.

NamesPredicate

A predicate type on names.

NameTypes

A union of a name type, or an iterable thereof.

Names

Acceptable name types.

Translatable#

Enumeration of translatable types.

The only truly Translatable types are int and str. Working with single IDs is rarely efficient in practice, so collections such as sequences (lists, tuples, numpy arrays) and dict values of sequences of primitives (or plain primitives) may be translated as well. Special handling is also implemented for pandas types.

alias of TypeVar(‘Translatable’, str, int, ~typing.Dict, ~typing.Sequence, NDArray, pandas.DataFrame, pandas.Index, pandas.Series)

ID: str = 'id'#

Name of the ID placeholder.

NameType#

Type used to label collections of IDs, such as the column names in a DataFrame or the keys of a dict.

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

IdType#

Type of the value being translated into human-readable labels.

alias of TypeVar(‘IdType’, int, str)

SourceType#

Type used to describe sources. Typically a string for things like files and database tables.

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

ExtendedOverrideFunction#

Signature for a user-defined override function.

Parameters:
  • name – A name to create a name-to-source match for.

  • sources – Potential matches for name.

  • ids – IDs for name.

Returns:

Either None (let regular logic decide), a dict, or a source.

If a dict, it is expected to be on the form {source: [ids_for_source..]}.

alias of Callable[[NameType, Set[SourceType], List[IdType]], Optional[Union[SourceType, Dict[SourceType, List[IdType]]]]]

NamesPredicate#

A predicate type on names.

alias of Callable[[NameType], bool]

NameTypes#

A union of a name type, or an iterable thereof.

alias of Union[NameType, Iterable[NameType]]

Names#

Acceptable name types.

alias of Union[NameType, Iterable[NameType], Callable[[NameType], bool]]