From ab7e08ed90d7f960959047c0e8c963dcb70ad038 Mon Sep 17 00:00:00 2001 From: Sam Insley Date: Wed, 8 Apr 2026 09:32:28 +0100 Subject: [PATCH 1/3] Fixed rounding bug --- bin/all_sky_search/pycbc_dtphase | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/all_sky_search/pycbc_dtphase b/bin/all_sky_search/pycbc_dtphase index 77f35e99bd1..964d65e9471 100644 --- a/bin/all_sky_search/pycbc_dtphase +++ b/bin/all_sky_search/pycbc_dtphase @@ -187,9 +187,9 @@ for ifo0 in args.ifos: dt = (data[ifo0]['t'] - data[ifo1]['t']) dp = (data[ifo0]['p'] - data[ifo1]['p']) % (2. * np.pi) sr = (data[ifo1]['s'] / data[ifo0]['s']) - dtbin = (dt / twidth).astype(int) - dpbin = (dp / pwidth).astype(int) - srbin = (sr / swidth).astype(int) + dtbin = np.rint(dt / twidth).astype(int) + dpbin = np.rint(dp / pwidth).astype(int) + srbin = np.rint(sr / swidth).astype(int) # We'll only store a limited range of ratios if keep is None: From 280d570ff074dcc31ace1541097634e2afd8409a Mon Sep 17 00:00:00 2001 From: Sam Insley Date: Thu, 9 Apr 2026 12:22:24 +0100 Subject: [PATCH 2/3] Applied rounding fix to the application to ensure symmetry with PTA histograms. --- pycbc/events/eventmgr_cython.pyx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pycbc/events/eventmgr_cython.pyx b/pycbc/events/eventmgr_cython.pyx index c0eebebf072..71507e07bae 100644 --- a/pycbc/events/eventmgr_cython.pyx +++ b/pycbc/events/eventmgr_cython.pyx @@ -2,7 +2,7 @@ import numpy as np cimport numpy as cnp import cython from cython import wraparound, boundscheck, cdivision -from libc.math cimport M_PI, sqrt +from libc.math cimport M_PI, sqrt, rint from libc.math cimport round as cround @@ -75,9 +75,9 @@ def logsignalrateinternals_computepsignalbins( sdif[idx] = (s[ridx] * sense * sqrt(sigref[ridx])) / (sref[ridx] * senseref * sqrt(sig[ridx])) for idx in range(length): - tbin[idx] = (tdif[idx] / twidth) - pbin[idx] = (pdif[idx] / pwidth) - sbin[idx] = (sdif[idx] / swidth) + tbin[idx] = rint(tdif[idx] / twidth) + pbin[idx] = rint(pdif[idx] / pwidth) + sbin[idx] = rint(sdif[idx] / swidth) @boundscheck(False) From f8cbc0ad8d02404e9e26cd67c88c47e9ee7fffbf Mon Sep 17 00:00:00 2001 From: Sam Insley Date: Tue, 21 Jul 2026 11:46:22 +0100 Subject: [PATCH 3/3] Applied bug fix to test live coinc --- test/validation_code/old_stat.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/validation_code/old_stat.py b/test/validation_code/old_stat.py index 4684b15e652..6cf78268deb 100644 --- a/test/validation_code/old_stat.py +++ b/test/validation_code/old_stat.py @@ -543,9 +543,9 @@ def logsignalrate(self, stats, shift, to_shift): sdif = s / sref * sense / senseref * sigref / sig # Put into bins - tbin = (tdif / self.twidth).astype(int) - pbin = (pdif / self.pwidth).astype(int) - sbin = (sdif / self.swidth).astype(int) + tbin = numpy.rint(tdif / self.twidth).astype(int) + pbin = numpy.rint(pdif / self.pwidth).astype(int) + sbin = numpy.rint(sdif / self.swidth).astype(int) binned += [tbin, pbin, sbin] # Convert binned to same dtype as stored in hist