torchsig.utils.printing.generate_repr_str¶
- torchsig.utils.printing.generate_repr_str(class_object: Any, exclude_params: list[str] = []) str[source]¶
Generates a string representation of the class object, excluding specified parameters.
This function creates a human-readable string representation of the given class object, including its class name and parameters. It excludes any parameters specified in the exclude_params list. If the class object is an instance of Seedable, certain attributes related to seeding are handled specifically.
- Parameters:
class_object (Any) – The class object to generate the string representation for.
exclude_params (List[str], optional) – A list of parameter names to exclude from the string representation. Defaults to an empty list.
- Returns:
A formatted string representation of the class object with parameters.
- Return type:
- Raises:
AttributeError – If the class object does not have a __dict__ attribute or any other required attributes for the operation.
Example
>>> class Example: >>> def __init__(self, param1, param2): >>> self.param1 = param1 >>> self.param2 = param2 >>> e = Example(1, 2) >>> generate_repr_str(e) 'Example(param1=1,param2=2)'
Notes
If the class object is an instance of Seedable, the seed and parent attributes will be added back into the string representation.