From 285be1f44be08629c61343c872e0b6c365833914 Mon Sep 17 00:00:00 2001 From: Setsugennoao <41454651+Setsugennoao@users.noreply.github.com> Date: Sun, 4 Aug 2024 15:07:34 +0200 Subject: [PATCH] Fix formatting --- vskernels/kernels/custom.py | 18 ++++++++++++++---- vskernels/kernels/spline.py | 18 +++++++++++++++--- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/vskernels/kernels/custom.py b/vskernels/kernels/custom.py index c2674d0..1687ed7 100644 --- a/vskernels/kernels/custom.py +++ b/vskernels/kernels/custom.py @@ -31,15 +31,25 @@ def kernel(x: float) -> float: return self.kernel, support @inject_self - def scale_function(self, clip: vs.VideoNode, width: int | None = None, height: int | None = None, *args: Any, **kwargs: Any) -> vs.VideoNode: - clean_kwargs = {k: v for k, v in kwargs.items() if k not in Signature.from_callable(self._modify_kernel_func).parameters.keys()} + def scale_function( + self, clip: vs.VideoNode, width: int | None = None, height: int | None = None, *args: Any, **kwargs: Any + ) -> vs.VideoNode: + clean_kwargs = { + k: v for k, v in kwargs.items() + if k not in Signature.from_callable(self._modify_kernel_func).parameters.keys() + } return core.resize2.Custom(clip, *self._modify_kernel_func(**kwargs), width, height, *args, **clean_kwargs) resample_function = scale_function @inject_self - def descale_function(self, clip: vs.VideoNode, width: int, height: int, *args: Any, **kwargs: Any) -> vs.VideoNode: - clean_kwargs = {k: v for k, v in kwargs.items() if k not in Signature.from_callable(self._modify_kernel_func).parameters.keys()} + def descale_function( + self, clip: vs.VideoNode, width: int, height: int, *args: Any, **kwargs: Any + ) -> vs.VideoNode: + clean_kwargs = { + k: v for k, v in kwargs.items() + if k not in Signature.from_callable(self._modify_kernel_func).parameters.keys() + } return core.descale.Decustom(clip, width, height, *self._modify_kernel_func(**kwargs), *args, **clean_kwargs) def get_params_args( diff --git a/vskernels/kernels/spline.py b/vskernels/kernels/spline.py index eae8cd6..229004b 100644 --- a/vskernels/kernels/spline.py +++ b/vskernels/kernels/spline.py @@ -40,9 +40,20 @@ def _naturalCubicSpline(self, values: list[int]) -> list[float]: # right value = sample eqns += [[0] * (4 * i) + [(i + 1) ** 3, (i + 1) ** 2, i + 1, 1] + [0] * (4 * (n - i - 1)) for i in range(n)] # derivatives match - eqns += [[0] * (4 * i) + [3 * (i + 1) ** 2, 2 * (i + 1), 1, 0] + [-3 * (i + 1) ** 2, -2 * (i + 1), -1, 0] + [0] * (4 * (n - i - 2)) for i in range(n - 1)] + eqns += [ + ( + [0] * (4 * i) + + [3 * (i + 1) ** 2, 2 * (i + 1), 1, 0] + + [-3 * (i + 1) ** 2, -2 * (i + 1), -1, 0] + + [0] * (4 * (n - i - 2)) + ) + for i in range(n - 1) + ] # second derivatives match - eqns += [[0] * (4 * i) + [6 * (i + 1), 2, 0, 0] + [-6 * (i + 1), -2, 0, 0] + [0] * (4 * (n - i - 2)) for i in range(n - 1)] + eqns += [ + [0] * (4 * i) + [6 * (i + 1), 2, 0, 0] + [-6 * (i + 1), -2, 0, 0] + [0] * (4 * (n - i - 2)) + for i in range(n - 1) + ] eqns += [[0, 2, 0, 0] + [0] * (4 * (n - 1))] eqns += [[0] * (4 * (n - 1)) + [6 * n ** 2, 2 * n, 0, 0]] @@ -57,7 +68,8 @@ def _splineKernelCoeff(self) -> list[float]: def _shiftPolynomial(coeffs: list[float], shift: float) -> list[float]: return [ - sum(c * comb(k, m) * (-shift) ** max(0, k - m) for k, c in enumerate(coeffs[::-1])) for m in range(len(coeffs)) + sum(c * comb(k, m) * (-shift) ** max(0, k - m) for k, c in enumerate(coeffs[::-1])) + for m in range(len(coeffs)) ][::-1] for i in range(taps):