Skip to content

Fixed rounding bug in pycbc_dtphase#5318

Open
SamInsley wants to merge 2 commits into
gwastro:masterfrom
SamInsley:BugFix
Open

Fixed rounding bug in pycbc_dtphase#5318
SamInsley wants to merge 2 commits into
gwastro:masterfrom
SamInsley:BugFix

Conversation

@SamInsley

Copy link
Copy Markdown

When binning samples into integer bins, the current code truncates the samples rather than consistently rounding. This results in the 0 bin having approximately twice as many samples as the others. This fix will round the samples to the nearest integer instead.

This is a bug fix regarding how samples are rounded.

This change changes: scientific output

This change: follows style guidelines (See e.g. PEP8), has been proposed using the contribution guidelines

This change will: it should not affect anything other than slightly changing the weights of different bins in the PTA histograms.

Motivation

The current version, truncates samples resulting in all samples between -1 and 1 being sorted into the zero bin. This causes an over-density in this bin compared to others.

Contents

Rather than truncating the samples, this simply rounds the samples to the nearest integer.

Links to any issues or associated PRs

Testing performed

I have recreated the histogram files with this change and it works the same just without this over density at 0.

Additional notes

  • The author of this pull request confirms they will adhere to the code of conduct

@titodalcanton titodalcanton added the bug BUG - FIX ASAP label Apr 8, 2026
@titodalcanton

Copy link
Copy Markdown
Contributor

Thanks @SamInsley! Could you please post plots of the histograms before/after the fix?

@SamInsley

SamInsley commented Apr 8, 2026

Copy link
Copy Markdown
Author

@titodalcanton
PTA_histogram

@tdent
tdent requested a review from ahnitz April 8, 2026 16:18
@ahnitz

ahnitz commented Apr 8, 2026

Copy link
Copy Markdown
Member

@titodalcanton @SamInsley If you make this change, the application should naturally also have a symmetric change, no?

e.g. Do you not also need to test the application here https://github.com/gwastro/pycbc/blob/master/pycbc/events/eventmgr_cython.pyx#L39?

@ahnitz ahnitz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment, I suspect you need to test a symmetric change on the application side.

@SamInsley

SamInsley commented Apr 9, 2026

Copy link
Copy Markdown
Author

@ahnitz Thanks! The fix also did need to be applied to where we bin the triggers. I have done this and it seems to be working fine in my personal tests, but these automatic tests are still failing and I am not sure why. I don't know if I am understanding it right but do these tests check if the stat values are consistent across both versions, as this fix will definitely have an affect on the measured stat values in some parts of the parameter space.

@SamInsley

Copy link
Copy Markdown
Author

@titodalcanton @ahnitz. I believe this is failing the tests because of test_live_coinc_compare.py. Since it will use pre-generated histogram files, the output density values will not be the same with this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug BUG - FIX ASAP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants