rics.mapping.support#

Functions and classes used by the Mapper for handling score matrices.

Warning

This module is considered an implementation detail, and may change without notice.

Functions

enable_verbose_debug_messages()

Temporarily enable verbose DEBUG-level logger messages.

Classes

MatchScores(scores, min_score)

High-level selection operations.

enable_verbose_debug_messages() Generator[None, None, None][source]#

Temporarily enable verbose DEBUG-level logger messages.

Returns a context manager. Calling the function without the with statement does nothing.

>>> from rics.mapping import Mapper, support
>>> with support.enable_verbose_debug_messages():
...     Mapper().apply('ab', candidates='abc')
class MatchScores(scores: DataFrame, min_score: float)[source]#

Bases: object

High-level selection operations.

Parameters:
  • scores – A score matrix, where scores.index are values and score.columns are treated as the candidates.

  • min_score – Minimum score to consider make a value -> candidate match.

to_directional_mapping(cardinality: Cardinality | None = None) DirectionalMapping[ValueType, CandidateType][source]#

Create a DirectionalMapping with a given target Cardinality.

Parameters:

cardinality – Explicit cardinality to set, see cardinality. If None, use the actual cardinality when selecting all matches with scores above the minimum.

Returns:

A DirectionalMapping.

above() List[Record[ValueType, CandidateType]][source]#

Get all records with scores above the threshold.

below() List[Record[ValueType, CandidateType]][source]#

Get all records with scores below the threshold.

class Record(value: ValueType, candidate: CandidateType, score: float)[source]#

Bases: Generic[ValueType, CandidateType]

Data concerning a match.

value: ValueType#

A hashable value.

candidate: CandidateType#

A hashable candidate.

score: float#

Likeness score computed by some scoring function.

class Reject(record: Record[ValueType, CandidateType], superseding_value: Record[ValueType, CandidateType] | None = None, superseding_candidate: Record[ValueType, CandidateType] | None = None)[source]#

Bases: Generic[ValueType, CandidateType]

Data concerning the rejection of a match.

record: Record[ValueType, CandidateType]#
superseding_value: Record[ValueType, CandidateType] | None = None#
superseding_candidate: Record[ValueType, CandidateType] | None = None#
explain(min_score: float, full: bool = False) str[source]#

Create a string which explains the rejection.

Parameters:
  • min_score – Minimum score to accept a match.

  • full – If True show full information about superseding matches.

Returns:

An explanatory string.