-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tvbd_diff: Add write_log
option
#40
Conversation
@@ -483,7 +483,9 @@ def stack_planes(clip: vs.VideoNode, /, stack_vertical: bool = False) -> vs.Vide | |||
def tvbd_diff(tv: vs.VideoNode, bd: vs.VideoNode, | |||
thr: float = 72, | |||
height: int = 288, | |||
return_array: bool = False) -> vs.VideoNode: | |||
return_array: bool = False, | |||
write_log: bool = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i feel like we should just pass a file handle (maybe typing.Optional[typing.TextIO]
?), then the caller can prepend/append any extra data they want (like episode name) as well as use a specific path
another option is just returning the list and letting the caller deal with it/letting them just process the data however they want
lvsfunc/comparison.py
Outdated
@@ -536,6 +541,23 @@ def tvbd_diff(tv: vs.VideoNode, bd: vs.VideoNode, | |||
if not frames: | |||
raise ValueError("tvbd_diff: no differences found") | |||
|
|||
if write_log: | |||
from itertools import groupby, count |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
itertools is pretty standard so there's not really a reason to defer this import rather than putting it at the top of the py file
lvsfunc/comparison.py
Outdated
if write_log: | ||
from itertools import groupby, count | ||
|
||
def intervals(frames: list) -> list: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no real reason to nest this this deeply, can just make it a top-level function like _get_diff_intervals
also the correct typehint for frames
should be typing.List[int]
and it returns typing.List[typing.Tuple[int, int]]
return out | ||
|
||
with open('./diff.log', 'a') as log: | ||
if ep_name: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as per above, this can be handled by the caller
lvsfunc/comparison.py
Outdated
from itertools import groupby, count | ||
|
||
def intervals(frames: list) -> list: | ||
out = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably needs typehinted
lvsfunc/comparison.py
Outdated
out = [] | ||
counter = count() | ||
|
||
for key, group in groupby(frames, key=lambda x: x - next(counter)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use _
for key
as a placeholder to make linters happier since it's unused
On second thought, maybe just add the ability to return return frames, Stack((tvbd_stack, diff), direction=Direction.VERTICAL).clip That would be enough for me. |
i think returning the frame list would be a good option |
For example:
will create
./diff.log
that contains: