Skip to content

Commit

Permalink
ExprOp: add support for ConvMode.TEMPORAL (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ichunjo authored Jan 14, 2025
1 parent 726a7de commit 08099c4
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
Expand Up @@ -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()

Expand All @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 08099c4

Please sign in to comment.