Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions data_juicer/ops/mapper/video_split_by_scene_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class VideoSplitBySceneMapper(Mapper):
"""Mapper to cut videos into scene clips."""

# Define shared detector keys and their properties
avaliable_detectors = {
available_detectors = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to PEP 8, constants should be named using UPPER_CASE_WITH_UNDERSCORES1. Renaming available_detectors to AVAILABLE_DETECTORS will make it clearer that this is a class-level constant and improve overall code readability.

Style Guide References

Suggested change
available_detectors = {
AVAILABLE_DETECTORS = {

Footnotes

  1. PEP 8 specifies that constants should be written in all capital letters with underscores separating words. This applies to module-level and class-level constants.

"ContentDetector": ["weights", "luma_only", "kernel_size"],
"AdaptiveDetector": [
"window_width",
Expand Down Expand Up @@ -66,10 +66,10 @@ def __init__(
super().__init__(*args, **kwargs)
self._init_parameters = self.remove_extra_parameters(locals())

if detector not in self.avaliable_detectors:
if detector not in self.available_detectors:
raise ValueError(
f"Scene detector {detector} is not supported. "
f"Can only be one of {list(self.avaliable_detectors.keys())}"
f"Can only be one of {list(self.available_detectors.keys())}"
Comment on lines +69 to +72
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To maintain consistency with the proposed change of available_detectors to AVAILABLE_DETECTORS (in accordance with PEP 8 naming conventions for constants1), this usage should be updated as well.

Style Guide References

Suggested change
if detector not in self.available_detectors:
raise ValueError(
f"Scene detector {detector} is not supported. "
f"Can only be one of {list(self.avaliable_detectors.keys())}"
f"Can only be one of {list(self.available_detectors.keys())}"
if detector not in self.AVAILABLE_DETECTORS:
raise ValueError(
f"Scene detector {detector} is not supported. "
f"Can only be one of {list(self.AVAILABLE_DETECTORS.keys())}"
)

Footnotes

  1. PEP 8 specifies that constants should be written in all capital letters with underscores separating words. This applies to module-level and class-level constants.

)

self.detector = detector
Expand All @@ -78,9 +78,9 @@ def __init__(
self.show_progress = show_progress

# prepare detector args
avaliable_kwargs = self.avaliable_detectors[self.detector]
available_kwargs = self.available_detectors[self.detector]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To maintain consistency with the proposed change of available_detectors to AVAILABLE_DETECTORS (in accordance with PEP 8 naming conventions for constants1), this usage should be updated.

Style Guide References

Suggested change
available_kwargs = self.available_detectors[self.detector]
available_kwargs = self.AVAILABLE_DETECTORS[self.detector]

Footnotes

  1. PEP 8 specifies that constants should be written in all capital letters with underscores separating words. This applies to module-level and class-level constants.

self.detector_class = getattr(scenedetect.detectors, self.detector)
self.detector_kwargs = {key: kwargs[key] for key in avaliable_kwargs if key in kwargs}
self.detector_kwargs = {key: kwargs[key] for key in available_kwargs if key in kwargs}

def process_single(self, sample, context=False):
# there is no video in this sample
Expand Down