nirs4all.utils.operator_formatting module

Utility functions for formatting operators with their parameters.

nirs4all.utils.operator_formatting.format_operator_with_params(operator: Any, short_name: str | None = None) → str[source]

Format an operator name with its non-default parameters.

Parameters:
  • operator – The operator instance to format

  • short_name – Optional short name to use instead of class name

Returns:

Formatted string like “SNV(alpha=0.5)” or just “SNV” if no params differ

Examples

>>> from sklearn.preprocessing import StandardScaler
>>> scaler = StandardScaler(with_mean=False)
>>> format_operator_with_params(scaler)
'StandardScaler(with_mean=False)'
>>> format_operator_with_params(scaler, "Std")
'Std(with_mean=False)'