Skip to content

Commit

Permalink
Rename kernel_size to kernel_radius
Browse files Browse the repository at this point in the history
  • Loading branch information
Setsugennoao committed Nov 11, 2023
1 parent 3ef3cb6 commit 470d9f3
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
20 changes: 10 additions & 10 deletions vskernels/kernels/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
]


def _default_kernel_size(cls, self) -> int:
if hasattr(self, '_static_kernel_size'):
return ceil(self._static_kernel_size)
def _default_kernel_radius(cls, self) -> int:
if hasattr(self, '_static_kernel_radius'):
return ceil(self._static_kernel_radius)

try:
return super(cls, self).kernel_size
return super(cls, self).kernel_radius
except AttributeError:
...

Expand Down Expand Up @@ -133,8 +133,8 @@ def multi(
return self.scale(clip, dst_width, dst_height, shift, **kwargs)

@inject_self.property
def kernel_size(self) -> int:
return _default_kernel_size(__class__, self)
def kernel_radius(self) -> int:
return _default_kernel_radius(__class__, self)


class Descaler(vs_object):
Expand Down Expand Up @@ -182,8 +182,8 @@ def ensure_obj(
return BaseScaler.ensure_obj(cls, Descaler, descaler, UnknownDescalerError, [], func_except) # type: ignore

@inject_self.property
def kernel_size(self) -> int:
return _default_kernel_size(__class__, self)
def kernel_radius(self) -> int:
return _default_kernel_radius(__class__, self)


class Resampler(vs_object):
Expand All @@ -207,8 +207,8 @@ def ensure_obj(
return BaseScaler.ensure_obj(cls, Resampler, resampler, UnknownDescalerError, [], func_except) # type: ignore

@inject_self.property
def kernel_size(self) -> int:
return _default_kernel_size(__class__, self)
def kernel_radius(self) -> int:
return _default_kernel_radius(__class__, self)


class Kernel(Scaler, Descaler, Resampler):
Expand Down
6 changes: 3 additions & 3 deletions vskernels/kernels/bicubic.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def get_params_args(
return args | dict(filter_param_a=self.b, filter_param_b=self.c)

@inject_self.property
def kernel_size(self) -> int:
def kernel_radius(self) -> int:
if (self.b, self.c) == (0, 0):
return 1
return 2
Expand Down Expand Up @@ -273,5 +273,5 @@ def _get_bc_args(self) -> tuple[float, float]:
return autob, autoc

@inject_self.property
def kernel_size(self) -> int:
return Bicubic(*self._get_bc_args()).kernel_size
def kernel_radius(self) -> int:
return Bicubic(*self._get_bc_args()).kernel_radius
2 changes: 1 addition & 1 deletion vskernels/kernels/fmtconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def _shift(shift_top: float | list[float] = 0.0, shift_left: float | list[float]
return _shift(shifts_top, shifts_left)

@inject_self.property
def kernel_size(self) -> int:
def kernel_radius(self) -> int:
taps_hv = self.kwargs.get('taps_h', self.kwargs.get('taps_v', None))

if taps_hv is None:
Expand Down
4 changes: 2 additions & 2 deletions vskernels/kernels/placebo.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ def get_params_args(
)

@inject_self.property
def kernel_size(self) -> int:
def kernel_radius(self) -> int:
from .bicubic import Bicubic

if self.taps:
return ceil(self.taps)

if self.b or self.c:
return Bicubic(self.b, self.c).kernel_size
return Bicubic(self.b, self.c).kernel_radius

return 2
6 changes: 3 additions & 3 deletions vskernels/kernels/resize.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ class Point(ZimgComplexKernel):
"""Built-in point resizer."""

scale_function = resample_function = descale_function = core.lazy.resize.Point
_static_kernel_size = 1
_static_kernel_radius = 1


class Bilinear(ZimgComplexKernel):
"""Built-in bilinear resizer."""

scale_function = resample_function = core.lazy.resize.Bilinear
descale_function = core.lazy.descale.Debilinear
_static_kernel_size = 1
_static_kernel_radius = 1


class Lanczos(ZimgComplexKernel):
Expand Down Expand Up @@ -56,5 +56,5 @@ def get_params_args(
return args | dict(filter_param_a=self.taps)

@inject_self.property
def kernel_size(self) -> int:
def kernel_radius(self) -> int:
return ceil(self.taps)
6 changes: 3 additions & 3 deletions vskernels/kernels/spline.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Spline16(ZimgComplexKernel):

scale_function = resample_function = core.lazy.resize.Spline16
descale_function = core.lazy.descale.Despline16
_static_kernel_size = 2
_static_kernel_radius = 2


class Spline36(ZimgComplexKernel):
Expand All @@ -49,7 +49,7 @@ class Spline36(ZimgComplexKernel):

scale_function = resample_function = core.lazy.resize.Spline36
descale_function = core.lazy.descale.Despline36
_static_kernel_size = 3
_static_kernel_radius = 3


class Spline64(ZimgComplexKernel):
Expand All @@ -63,4 +63,4 @@ class Spline64(ZimgComplexKernel):

scale_function = resample_function = core.lazy.resize.Spline64
descale_function = core.lazy.descale.Despline64
_static_kernel_size = 4
_static_kernel_radius = 4
2 changes: 1 addition & 1 deletion vskernels/kernels/various.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def __init__(self, b: float = 0.0, c: float = 0.5, radius: int | None = None, **
if radius is None:
from .bicubic import Bicubic

radius = Bicubic(b, c).kernel_size
radius = Bicubic(b, c).kernel_radius

super().__init__(radius, b, c, **kwargs)

Expand Down

0 comments on commit 470d9f3

Please sign in to comment.