Skip to content

Flagger Translations

David Schäfer requested to merge translations into develop

Implements the basic translation machinery and translation schemes for the former DmpFlagger and PositionalFlagger.

Description

The class saqc.core.translator.Translator provides the basic interface and implementation for all other translation schemes. Currently Translator provides three methods:

  • forward: to translate user flags to internal flags (pd.DataFrame -> Flags)
  • __call__: to translate a user flag into an internal flag (str | int | float -> float)
  • backward: to translate internal flags to user flags (Flags -> pd.DataFrame)

Three translator implementations currently exists:

  • saqc.core.translator.DmpTranslator: implements the DMP flagging scheme
  • saqc.core.translator.PositionalFlagger: implements the positional flagging scheme
  • saqc.core.translator.FloatTranslator: serves as the default translation schemes but only provides the flags {-np.inf, 0..255}. This restriction is arbitrary and can be relaxed if needed.

The integration into the entire system is done within the core, namely in saqc.core.core._wrap.inner. Here every flag is translated as soon as it reaches the SaQC object. Within the system only the internal float-flags will be passed around, the final (and only) back translation occurs in SaQC.getResult.

To ensure consistency with the translation scheme (chosen in SaQC.__init__) only flag values available in the respective scheme are allowed, which leads to #183 (closed) . To ensure consistency with the translation scheme (chosen in SaQC.__init__) and to address #183 (closed), the user and the internal flags provided in the translation scheme (i.e. the keys and the values of the respective dict) are accepted (but no others)

Currently it is not clear, if the current flags/history implementation is general enough to support the PositionalTranslator (see #182 (closed)). For the time being, we work around the concerns raises in #182 (closed) within the translations.

To the reviewer

Ready for review @palmb and @luenensc. There are (quite a) few unrelated changes, mostly fixes of comments, trailing whitespaces and type hints. I know, that the disturb the review process, but as I stumbled upon them, I fixed them along the way. The main changes concentrate on the files:

  • sacq/core/translator.py and the respective tests in tests/core/test_translator.py
  • saqc/core/core.py.
Edited by David Schäfer

Merge request reports

Loading