Skip to content

testcomp

TestCompiler(n_features, testinputs)

Transforms abstract test inputs into executable test inputs.

Compatible with Flowcean models.

Attributes:

n_features: int Number of features in the dataset.

list

List of abstract test inputs.

Methods:

compute_executable_testinputs() Converts abstract test inputs into a polars DataFrame for execution.

Initializes the TestCompiler.

Parameters:

Name Type Description Default
n_features int

Number of features in the dataset.

required
testinputs list

List of abstract test inputs.

required
Source code in src/flowcean/testing/generator/ddtig/domain/test_generator/testcomp.py
23
24
25
26
27
28
29
30
31
32
33
34
35
def __init__(
    self,
    n_features: int,
    testinputs: list,
) -> None:
    """Initializes the TestCompiler.

    Args:
        n_features: Number of features in the dataset.
        testinputs: List of abstract test inputs.
    """
    self.n_features = n_features
    self.abst_testinputs = testinputs

compute_executable_testinputs(feature_names)

Convert abstract test inputs into a Polars DataFrame.

Thus, the result can be executed on Flowcean models.

Parameters:

Name Type Description Default
feature_names list

List of feature names in order of their indices.

required

Returns:

Type Description
DataFrame

DataFrame where each column represents a feature

DataFrame

and each row represents a test input.

Source code in src/flowcean/testing/generator/ddtig/domain/test_generator/testcomp.py
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
def compute_executable_testinputs(
    self,
    feature_names: list,
) -> pl.DataFrame:
    """Convert abstract test inputs into a Polars DataFrame.

    Thus, the result can be executed on Flowcean models.

    Args:
        feature_names: List of feature names in order of their indices.

    Returns:
        DataFrame where each column represents a feature
        and each row represents a test input.
    """
    input_dict = self._init_input_dict()

    # Populate input dictionary with values from abstract test inputs
    for ati in self.abst_testinputs:
        for feature, value in enumerate(ati):
            input_dict[str(feature)].append(value)
    input_dict = dict(
        zip(feature_names, list(input_dict.values()), strict=False),
    )

    # Convert to polars DataFrame (Flowcean-compatible format)
    return pl.from_dict(input_dict, strict=False)