From b04b604e57bd8d6264dbae01edc630677ffd42e5 Mon Sep 17 00:00:00 2001 From: LightArrowsEXE Date: Fri, 1 Nov 2024 21:46:34 +0100 Subject: [PATCH] BaseScaler: Add `pretty_string` property Requested by @Vodes. --- vskernels/kernels/abstract.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vskernels/kernels/abstract.py b/vskernels/kernels/abstract.py index bb80627..6a67426 100644 --- a/vskernels/kernels/abstract.py +++ b/vskernels/kernels/abstract.py @@ -199,6 +199,19 @@ def kernel_radius(self) -> int: def get_clean_kwargs(self, *funcs: Callable[..., Any] | None) -> KwargsT: return _clean_self_kwargs(funcs, self) + @inject_self.cached.property + def pretty_string(self) -> str: + attrs = {} + + if hasattr(self, 'b'): + attrs.update(b=self.b, c=self.c) + elif hasattr(self, 'taps'): + attrs['taps'] = self.taps + + if hasattr(self, 'kwargs'): + attrs.update(self.kwargs) + + return f"{self.__class__.__name__}{' (' + ', '.join(f'{k}={v}' for k, v in attrs.items()) + ')' if attrs else ''}" BaseScalerT = TypeVar('BaseScalerT', bound=BaseScaler)