Skip to content

Support function call groups

David Schäfer requested to merge logicals into develop

While thinking about #390 (closed) as another solution to #382 (closed) I came up with the idea, that functions to aggregate flags from several SaQC would likely solve most of the needed behavior. This MR implements a first limited version of and and or merging of flags from different SaQC objects. With this, we are able to do grouping like behavior like:

qc = SaQC(data)

qc = qc.logicalAnd(
    "a",
    qcs=[
        qc.flagRange("a", min=10, max=100),
        qc.flagConstants("a", thresh=0.001, window="24h"),
        qc.flagGeneric(["a", "b"], target="a", func=lambda a, b: a > b),
    ],
)

Currently we have the limitation, that the methods only work on the given field. That means, that in the given example a needs to be present in all objects in qcs and we don't allow to logically combine flags from different variables. For the moment, I think this is acceptable, but the necessity might arise. If so one solution would be to type qcs: Sequence[SaQC] | dict[SaQC, str] and provide the fields to merge as the dictionary values (e.g. qcs={qc1: "a", qc2: "b", qc3: "a"}

Edited by David Schäfer

Merge request reports