Skip to content

Commit

Permalink
BaseScaler: Add pretty_string property
Browse files Browse the repository at this point in the history
Requested by @Vodes.
  • Loading branch information
LightArrowsEXE committed Nov 1, 2024
1 parent 28622dd commit b04b604
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions vskernels/kernels/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit b04b604

Please sign in to comment.