Skip to content

Commit 69686cb

Browse files
committed
Fix 'repeast_last' doc and associated type annotation
1 parent 5a0f14c commit 69686cb

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/torchcodec/samplers/_index_based.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,13 @@ def clips_at_regular_indices(
261261
invalid indices, so the ``policy`` parameter defines how to replace
262262
those frames, with valid indices:
263263
264-
- "repeat": repeats the last valid frame of the clip. We would get
265-
[95, 97, 99, 99, 99].
264+
- "repeat_last": repeats the last valid frame of the clip. We would
265+
get [95, 97, 99, 99, 99].
266266
- "wrap": wraps around to the beginning of the clip. We would get
267267
[95, 97, 99, 95, 97].
268268
- "error": raises an error.
269269
270-
Default is "repeat". Note that when ``sampling_range_end=None``
270+
Default is "repeat_last". Note that when ``sampling_range_end=None``
271271
(default), this policy parameter is unlikely to be relevant.
272272
273273
{_FRAMEBATCH_RETURN_DOCS}

src/torchcodec/samplers/_time_based.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def _generic_time_based_sampler(
157157
# None means "begining", which may not always be 0
158158
sampling_range_start: Optional[float],
159159
sampling_range_end: Optional[float], # interval is [start, end).
160-
policy: str = "repeat_last",
160+
policy: Literal["repeat_last", "wrap", "error"] = "repeat_last",
161161
) -> FrameBatch:
162162
# Note: *everywhere*, sampling_range_end denotes the upper bound of where a
163163
# clip can start. This is an *open* upper bound, i.e. we will make sure no
@@ -227,7 +227,7 @@ def clips_at_random_timestamps(
227227
# None means "begining", which may not always be 0
228228
sampling_range_start: Optional[float] = None,
229229
sampling_range_end: Optional[float] = None, # interval is [start, end).
230-
policy: str = "repeat_last",
230+
policy: Literal["repeat_last", "wrap", "error"] = "repeat_last",
231231
) -> FrameBatch:
232232
return _generic_time_based_sampler(
233233
kind="random",
@@ -251,7 +251,7 @@ def clips_at_regular_timestamps(
251251
# None means "begining", which may not always be 0
252252
sampling_range_start: Optional[float] = None,
253253
sampling_range_end: Optional[float] = None, # interval is [start, end).
254-
policy: str = "repeat_last",
254+
policy: Literal["repeat_last", "wrap", "error"] = "repeat_last",
255255
) -> FrameBatch:
256256
return _generic_time_based_sampler(
257257
kind="regular",
@@ -306,13 +306,13 @@ def clips_at_regular_timestamps(
306306
timestamps, so the ``policy`` parameter defines how to replace those
307307
frames, with valid sampling timestamps:
308308
309-
- "repeat": repeats the last valid frame of the clip. We would get
310-
frames sampled at timestamps [10.5, 10.7, 10.9, 10.9, 10.9].
309+
- "repeat_last": repeats the last valid frame of the clip. We would
310+
get frames sampled at timestamps [10.5, 10.7, 10.9, 10.9, 10.9].
311311
- "wrap": wraps around to the beginning of the clip. We would get
312312
frames sampled at timestamps [10.5, 10.7, 10.9, 10.5, 10.7].
313313
- "error": raises an error.
314314
315-
Default is "repeat". Note that when ``sampling_range_end=None``
315+
Default is "repeat_last". Note that when ``sampling_range_end=None``
316316
(default), this policy parameter is unlikely to be relevant.
317317
318318
{return_docs}

0 commit comments

Comments
 (0)