diff options
Diffstat (limited to 'libs/ffsubsync/aligners.py')
-rw-r--r-- | libs/ffsubsync/aligners.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/libs/ffsubsync/aligners.py b/libs/ffsubsync/aligners.py index f02243dd2..28b7bcf9d 100644 --- a/libs/ffsubsync/aligners.py +++ b/libs/ffsubsync/aligners.py @@ -34,13 +34,16 @@ class FFTAligner(TransformerMixin): convolve = np.copy(convolve) if self.max_offset_samples is None: return convolve - offset_to_index = lambda offset: len(convolve) - 1 + offset - len(substring) - convolve[: offset_to_index(-self.max_offset_samples)] = float("-inf") - convolve[offset_to_index(self.max_offset_samples) :] = float("-inf") + + def _offset_to_index(offset): + return len(convolve) - 1 + offset - len(substring) + + convolve[: _offset_to_index(-self.max_offset_samples)] = float("-inf") + convolve[_offset_to_index(self.max_offset_samples) :] = float("-inf") return convolve def _compute_argmax(self, convolve: np.ndarray, substring: np.ndarray) -> None: - best_idx = np.argmax(convolve) + best_idx = int(np.argmax(convolve)) self.best_offset_ = len(convolve) - 1 - best_idx - len(substring) self.best_score_ = convolve[best_idx] |