Skip to content

utils

Filtering utils.

Functions:

Name Description
extract_feature_from_exposed

Extract feature from exposed feature.

extract_base_feature_from_exposed

Extract feature from exposed feature.

extract_feature_from_exposed(exposed_feature: ExposedFeature) -> Feature | Metadata #

Extract feature from exposed feature.

Source code in src/xpdeep/dataset/schema/feature/utils.py
def extract_feature_from_exposed(  # noqa: PLR0911
    exposed_feature: ExposedFeature,
) -> Feature | Metadata:
    """Extract feature from exposed feature."""
    if isinstance(exposed_feature, ExposedNumericalFeature):
        return NumericalFeature.from_exposed(exposed_feature)

    if isinstance(exposed_feature, ExposedCategoricalFeature):
        return CategoricalFeature.from_exposed(exposed_feature)

    if isinstance(exposed_feature, ExposedMultivariateNumericalFeature):
        return MultivariateNumericalFeature.from_exposed(exposed_feature)

    if isinstance(exposed_feature, ExposedUnivariateSynchronousTimeSerie):
        return UnivariateSynchronousTimeSerie.from_exposed(exposed_feature)

    if isinstance(exposed_feature, ExposedUnivariateAsynchronousTimeSerie):
        return UnivariateAsynchronousTimeSerie.from_exposed(exposed_feature)

    if isinstance(exposed_feature, ExposedMultivariateSynchronousTimeSerie):
        return MultivariateSynchronousTimeSerie.from_exposed(exposed_feature)

    if isinstance(exposed_feature, ExposedMultivariateAsynchronousTimeSerie):
        return MultivariateAsynchronousTimeSerie.from_exposed(exposed_feature)

    if isinstance(exposed_feature, ExposedMetadata):
        return Metadata.from_exposed(exposed_feature)

    msg = f"Unsupported feature: {exposed_feature}"
    raise TypeError(msg)

extract_base_feature_from_exposed(exposed_feature: ExposedFeature | ExposedBaseFeature) -> Feature | BaseFeature | Metadata #

Extract feature from exposed feature.

Source code in src/xpdeep/dataset/schema/feature/utils.py
def extract_base_feature_from_exposed(
    exposed_feature: ExposedFeature | ExposedBaseFeature,
) -> Feature | BaseFeature | Metadata:
    """Extract feature from exposed feature."""
    if isinstance(exposed_feature, ExposedFeature):
        return extract_feature_from_exposed(exposed_feature)

    if isinstance(exposed_feature, ExposedBaseFeature):
        return BaseFeature.from_exposed(exposed_feature)

    msg = f"Unsupported feature: {exposed_feature}"  # type: ignore[unreachable]
    raise TypeError(msg)