From 0b967b9e18e511bbeb08e2ecd5fe475f835353f1 Mon Sep 17 00:00:00 2001 From: Tim Molteno Date: Mon, 16 Dec 2024 13:14:08 +0200 Subject: [PATCH] Resolve overflow error. Fixes #96 --- tricolour/flagging.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tricolour/flagging.py b/tricolour/flagging.py index b91473f..d94a3bc 100644 --- a/tricolour/flagging.py +++ b/tricolour/flagging.py @@ -1170,13 +1170,7 @@ def sum_threshold_flagger(vis, flags, outlier_nsigma=4.5, freq_chunks = freq_chunks average_freq = _as_min_dtype(average_freq) - # BUG the following code is a terrible idea if nchan is on a dtype size boundary because adding - # anything to this will wrap. e.g. - # >>> x = np.array(255, np.uint8) - # >>> y = np.array(1, np.uint8) - # >>> x + y - # 0 - # >>> + # Casting to int fixes an overflow error... averaged_channels = (int(nchan) + int(average_freq) - 1) // int(average_freq) # Set up frequency chunks