-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix #180, add Lazy Operator * add test case * udpate test case * update snapshot * add partical * wip * wip * fix import path * fix * fix * update templ * update snapshot * docstrings * fix
- Loading branch information
Showing
47 changed files
with
941 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
::: ffmpeg.utils.lazy_eval.operator | ||
options: | ||
show_source: false | ||
members_order: source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
::: ffmpeg.utils.lazy_eval.schema | ||
options: | ||
show_source: false | ||
members_order: source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# serializer version: 1 | ||
# name: test_symbol | ||
OutputStream(node=OutputNode(kwargs=(), inputs=(VideoStream(node=FilterNode(kwargs=(('w', Symbol(key='w')),), inputs=(AVStream(node=InputNode(kwargs=(), inputs=(), filename='input.mp4'), index=None),), name='scale', input_typings=(<StreamType.video: 'video'>,), output_typings=(<StreamType.video: 'video'>,)), index=0),), filename='output.mp4'), index=None) | ||
# --- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from syrupy.assertion import SnapshotAssertion | ||
|
||
from ..base import input | ||
from ..utils.lazy_eval.schema import Symbol | ||
|
||
|
||
def test_symbol(snapshot: SnapshotAssertion) -> None: | ||
w = Symbol("w") | ||
|
||
assert snapshot() == input("input.mp4").scale(w=w).output(filename="output.mp4") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
from dataclasses import dataclass | ||
from typing import Any | ||
|
||
from .schema import LazyOperator | ||
|
||
|
||
@dataclass(frozen=True, kw_only=True) | ||
class Add(LazyOperator): | ||
""" | ||
A lazy operator for addition. | ||
""" | ||
|
||
def _eval(self, left: Any, right: Any) -> Any: | ||
return left + right | ||
|
||
def __str__(self) -> str: | ||
return f"({self.left}+{self.right})" | ||
|
||
|
||
@dataclass(frozen=True, kw_only=True) | ||
class Sub(LazyOperator): | ||
""" | ||
A lazy operator for subtraction. | ||
""" | ||
|
||
def _eval(self, left: Any, right: Any) -> Any: | ||
return left - right | ||
|
||
def __str__(self) -> str: | ||
return f"({self.left}-{self.right})" | ||
|
||
|
||
@dataclass(frozen=True, kw_only=True) | ||
class Mul(LazyOperator): | ||
""" | ||
A lazy operator for multiplication. | ||
""" | ||
|
||
def _eval(self, left: Any, right: Any) -> Any: | ||
return left * right | ||
|
||
def __str__(self) -> str: | ||
return f"({self.left}*{self.right})" | ||
|
||
|
||
@dataclass(frozen=True, kw_only=True) | ||
class TrueDiv(LazyOperator): | ||
""" | ||
A lazy operator for true division. | ||
""" | ||
|
||
def _eval(self, left: Any, right: Any) -> Any: | ||
return left / right | ||
|
||
def __str__(self) -> str: | ||
return f"({self.left}/{self.right})" | ||
|
||
|
||
@dataclass(frozen=True, kw_only=True) | ||
class Pow(LazyOperator): | ||
""" | ||
A lazy operator for exponentiation. | ||
""" | ||
|
||
def _eval(self, left: Any, right: Any) -> Any: | ||
return left**right | ||
|
||
def __str__(self) -> str: | ||
return f"({self.left}**{self.right})" | ||
|
||
|
||
@dataclass(frozen=True, kw_only=True) | ||
class Neg(LazyOperator): | ||
""" | ||
A lazy operator for negation. | ||
""" | ||
|
||
def _eval(self, left: Any, right: Any) -> Any: | ||
return -left | ||
|
||
def __str__(self) -> str: | ||
return f"-{self.left}" | ||
|
||
|
||
@dataclass(frozen=True, kw_only=True) | ||
class Pos(LazyOperator): | ||
""" | ||
A lazy operator for positive. | ||
""" | ||
|
||
def _eval(self, left: Any, right: Any) -> Any: | ||
return +left | ||
|
||
def __str__(self) -> str: | ||
return f"+{self.left}" | ||
|
||
|
||
@dataclass(frozen=True, kw_only=True) | ||
class Abs(LazyOperator): | ||
""" | ||
A lazy operator for absolute value. | ||
""" | ||
|
||
def _eval(self, left: Any, right: Any) -> Any: | ||
return abs(left) | ||
|
||
def __str__(self) -> str: | ||
return f"abs({self.left})" | ||
|
||
|
||
@dataclass(frozen=True, kw_only=True) | ||
class Mod(LazyOperator): | ||
""" | ||
A lazy operator for modulo. | ||
""" | ||
|
||
def _eval(self, left: Any, right: Any) -> Any: | ||
return left % right | ||
|
||
def __str__(self) -> str: | ||
return f"({self.left}%{self.right})" | ||
|
||
|
||
@dataclass(frozen=True, kw_only=True) | ||
class FloorDiv(LazyOperator): | ||
""" | ||
A lazy operator for floor division. | ||
""" | ||
|
||
def _eval(self, left: Any, right: Any) -> Any: | ||
return left // right | ||
|
||
def __str__(self) -> str: | ||
return f"({self.left}//{self.right})" |
Oops, something went wrong.