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

Change error handling behaviour

parent bcfc4e7f
No related branches found
No related tags found
No related merge requests found
...@@ -150,6 +150,7 @@ def corr(data, pos, w_size, max_tdoa, decimate=1, mode='prepare', hyper=True, ve ...@@ -150,6 +150,7 @@ def corr(data, pos, w_size, max_tdoa, decimate=1, mode='prepare', hyper=True, ve
tdoas[i, 1] += maxs tdoas[i, 1] += maxs
if hyper: if hyper:
with np.errstate(divide='ignore'):
tdoas2[i, :2], tdoas2[i, 2:] = _hyperres(tdoas[i, 2:], cc) tdoas2[i, :2], tdoas2[i, 2:] = _hyperres(tdoas[i, 2:], cc)
tdoas2[i, 1] += maxs tdoas2[i, 1] += maxs
tdoas[:, :2] *= 20 tdoas[:, :2] *= 20
...@@ -208,7 +209,7 @@ def main(args): ...@@ -208,7 +209,7 @@ def main(args):
try: try:
pos = np.arange(0, len(sound), int(sr * float(args.stride))) pos = np.arange(0, len(sound), int(sr * float(args.stride)))
except ValueError: except ValueError:
raise ValueError(f'Error: hop size {args.stride} is neither an existing file nor a float') raise ValueError(f'hop size {args.stride} is neither an existing file nor a float')
print("Computing TDOAs...") print("Computing TDOAs...")
results = corr(sound, pos, int(sr * args.frame_size), max_tdoa=int(np.ceil(sr * args.max_tdoa)), results = corr(sound, pos, int(sr * args.frame_size), max_tdoa=int(np.ceil(sr * args.max_tdoa)),
...@@ -353,5 +354,9 @@ if __name__ == "__main__": ...@@ -353,5 +354,9 @@ if __name__ == "__main__":
sys.exit(main(args)) sys.exit(main(args))
except Exception as e: except Exception as e:
print(type(e).__name__, e, sep=': ') trace = getattr(sys, 'gettrace', None)
if trace is not None:
if trace():
raise e from None
print(f'{BColors.WARNING}{type(e).__name__}: {e}{BColors.WARNING}')
sys.exit(2) sys.exit(2)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment