Skip to content
Snippets Groups Projects
Commit 0a17ce28 authored by ferrari's avatar ferrari
Browse files

Add a bound check for positions

parent 6f3b1d39
No related branches found
No related tags found
No related merge requests found
...@@ -206,6 +206,10 @@ def main(args): ...@@ -206,6 +206,10 @@ def main(args):
# Position where the TDOAs are computed # Position where the TDOAs are computed
if os.path.isfile(args.stride): if os.path.isfile(args.stride):
pos = (sr * np.loadtxt(args.stride, delimiter=',')).astype(int).ravel() pos = (sr * np.loadtxt(args.stride, delimiter=',')).astype(int).ravel()
if any(pos < 0) or any(pos >= len(sound)):
print(f'{BColors.WARNING}Discarding {np.sum(pos <0) + np.sum(pos >= len(sound))} out of bounds out of the '
f'{len(pos)} loaded positions{BColors.ENDC}')
pos = pos[(0 <= pos) & (pos < len(sound))]
else: else:
try: try:
pos = np.arange(0, len(sound), int(sr * float(args.stride))) pos = np.arange(0, len(sound), int(sr * float(args.stride)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment