From a002514cd3263639a164b5a34b29667a0d961abf Mon Sep 17 00:00:00 2001 From: ferrari <maxence.ferrari@gmail.com> Date: Wed, 22 Feb 2023 14:06:13 +0100 Subject: [PATCH] Change error handling behaviour --- gsrp_tdoa_hyperres.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gsrp_tdoa_hyperres.py b/gsrp_tdoa_hyperres.py index 345873c..731735e 100755 --- a/gsrp_tdoa_hyperres.py +++ b/gsrp_tdoa_hyperres.py @@ -150,7 +150,8 @@ def corr(data, pos, w_size, max_tdoa, decimate=1, mode='prepare', hyper=True, ve tdoas[i, 1] += maxs if hyper: - tdoas2[i, :2], tdoas2[i, 2:] = _hyperres(tdoas[i, 2:], cc) + with np.errstate(divide='ignore'): + tdoas2[i, :2], tdoas2[i, 2:] = _hyperres(tdoas[i, 2:], cc) tdoas2[i, 1] += maxs tdoas[:, :2] *= 20 if mode == 'smart': @@ -208,7 +209,7 @@ def main(args): try: pos = np.arange(0, len(sound), int(sr * float(args.stride))) 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...") 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__": sys.exit(main(args)) 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) -- GitLab