This PR introduces a new mixin, InitAwareRepr, aimed at providing more informative and concise string representations (__repr__) of objects. I only used it for FeatureExtractor because this is the original target of such a feature.
Motivation
When debugging or logging, it's often useful to know an object's initialization parameters. The default __repr__ might not always capture these details, making it harder to understand an object's state at a glance.
This is especially useful when we print the features that are used for the analysis, at the beginning. I think it increase transparency of what we are doing, and how it could be modified.
This could also be added to the logs to know how the features were initialized.
Features
Automatic capture of initialization arguments through a metaclass (InitAwareReprMeta).
Enhanced __repr__ method that uses captured initialization arguments.
Example Usage
class ExampleClass(InitAwareRepr):
def __init__(self, x, y):
self.x = x
self.y = y
e = ExampleClass(1, 2)
print(e) # Outputs: ExampleClass(x=1, y=2)
This ensures that whenever we print or log instances of classes using the InitAwareRepr mixin, we get a clearer view of their state based on their initialization parameters.
Notes
The goal is NOT to represent the state of a class, but just show how it was instantiated - and therefore how to instantiate it.
While writing these notes, I thought that instead of overwriting repr we should introduce a new method _init__repr ( or whatever).
What do you think? Feel free to be harsh on such a feature, I want a honest opinion
Description
This PR introduces a new mixin,
InitAwareRepr
, aimed at providing more informative and concise string representations (__repr__
) of objects. I only used it forFeatureExtractor
because this is the original target of such a feature.Motivation
When debugging or logging, it's often useful to know an object's initialization parameters. The default
__repr__
might not always capture these details, making it harder to understand an object's state at a glance.This is especially useful when we print the features that are used for the analysis, at the beginning. I think it increase transparency of what we are doing, and how it could be modified. This could also be added to the logs to know how the features were initialized.
Features
InitAwareReprMeta
).__repr__
method that uses captured initialization arguments.Example Usage
This ensures that whenever we print or log instances of classes using the
InitAwareRepr
mixin, we get a clearer view of their state based on their initialization parameters.Notes
_init__repr
( or whatever).What do you think? Feel free to be harsh on such a feature, I want a honest opinion