Feature Reset Helper

GitHub Link to Code.

Feature reset helper for managing feature data cleanup.

This module provides utilities for resetting and clearing feature data in the FeatureManager, handling both single and multiple feature resets with different error handling modes.

class mdxplain.feature.helper.feature_reset_helper.FeatureResetHelper

Helper class for feature reset operations.

Provides static methods for handling feature reset logic, including selective resets, error handling modes, and status reporting.

static reset_all_features(pipeline_data: PipelineData) None

Reset all features in the pipeline data.

Parameters

pipeline_dataPipelineData

Pipeline data object to reset

Returns

None

Clears all feature data and prints summary

Examples

>>> FeatureResetHelper.reset_all_features(pipeline_data)
Reset 3 feature(s): distances, contacts, angles
All feature data has been cleared. Features must be recalculated.
static reset_specific_features(pipeline_data: PipelineData, feature_types: List[Any], strict: bool = False) None

Reset specific feature types with optional strict error handling.

Parameters

pipeline_dataPipelineData

Pipeline data object to reset

feature_typesList[Any]

List of feature types to reset (strings, instances, or classes)

strictbool, default=False

Whether to raise errors for non-existent features

Returns

None

Resets specified features and prints status

Raises

ValueError

If strict=True and feature types are not found

Examples

>>> FeatureResetHelper.reset_specific_features(
...     pipeline_data, ["distances", "contacts"], get_key_fn
... )
Reset 2 feature(s): distances, contacts
static normalize_feature_types(feature_type: Any | List[Any]) List[Any]

Normalize feature_type parameter to list format.

Parameters

feature_typeFeatureType or List[FeatureType]

Single feature type or list of feature types

Returns

List[Str]

Normalized list of feature types

Examples

>>> types = FeatureResetHelper.normalize_feature_types("distances")
>>> print(types)
["distances"]
>>> types = FeatureResetHelper.normalize_feature_types(["distances", "contacts"])
>>> print(types)
["distances", "contacts"]
static check_has_features(pipeline_data: PipelineData) bool

Check if pipeline data has any features to reset.

Parameters

pipeline_dataPipelineData

Pipeline data object to check

Returns

bool

True if features exist, False otherwise

Examples

>>> has_features = FeatureResetHelper.check_has_features(pipeline_data)
>>> if not has_features:
...     print("No features to reset.")