Skip to content
This repository has been archived by the owner on Feb 27, 2025. It is now read-only.

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ExprOp: add support for ConvMode.TEMPORAL
Browse files Browse the repository at this point in the history
Ichunjo committed Jan 12, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 51a2511 commit 982f39a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions vsexprtools/exprop.py
Original file line number Diff line number Diff line change
@@ -259,7 +259,7 @@ def clamp(

@classmethod
def matrix(
cls, var: str, radius: int, mode: ConvMode, exclude: Iterable[tuple[int, int]] | None = None
cls, var: str | ExprVarsT, radius: int, mode: ConvMode, exclude: Iterable[tuple[int, int]] | None = None
) -> TupleExprList:
exclude = list(exclude) if exclude else list()

@@ -279,6 +279,14 @@ def matrix(
cls.matrix(var, radius, ConvMode.VERTICAL, exclude)[0],
cls.matrix(var, radius, ConvMode.HORIZONTAL, exclude)[0],
])
case ConvMode.TEMPORAL:
if len(var) != radius * 2 + 1:
raise CustomValueError(
"`var` must have a number of elements proportional to the radius",
cls.matrix, var
)

return TupleExprList([ExprList(v for v in var)])
case _:
raise NotImplementedError

@@ -291,7 +299,7 @@ def matrix(

@classmethod
def convolution(
cls, var: str, matrix: Iterable[SupportsFloat] | Iterable[Iterable[SupportsFloat]],
cls, var: str | ExprVarsT, matrix: Iterable[SupportsFloat] | Iterable[Iterable[SupportsFloat]],
bias: float | None = None, divisor: float | bool = True, saturate: bool = True,
mode: ConvMode = ConvMode.HV, premultiply: float | int | None = None,
multiply: float | int | None = None, clamp: bool = False

0 comments on commit 982f39a

Please sign in to comment.