-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spot-count histogram: use math.ceil instead of round #1660
Conversation
Python uses a rounding half to even strategy, which means that 1.5 and 2.5 both round to 2, which resulted inconsistency in the spot-count depending on whether there was an even or odd number of images.
🧐 It was that easy? I spent a while looking at this in the past, was evidently looking in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this - it was one of the more annoying "features" and I am genuinely shocked that the fix was this simple, but it presumably was so that's great!
@@ -95,3 +95,32 @@ def test_spot_counts_per_image_plot(dials_regression): | |||
1 image 10""" | |||
output = "\n".join(line.rstrip() for line in output.splitlines()) | |||
assert output == expected_output | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth having this test on e.g. 1...9 images of centroid test data to make sure that it works right for all the cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bug here was that the behaviour was inconsistent between even- and odd-length imagesets. We already had a test for output of even-length imagesets (1..10 above). I have added a test for an odd-length imageset below (1..3). We can change that to 1..9 if you think that would be better, but I don't think it would make any difference to the outcome.
You can see the old behaviour by doing:
With the changes in this PR, the behaviour is now as expected. |
Codecov Report
@@ Coverage Diff @@
## main #1660 +/- ##
==========================================
- Coverage 66.70% 66.69% -0.01%
==========================================
Files 616 616
Lines 69057 69062 +5
Branches 9606 9607 +1
==========================================
- Hits 46063 46062 -1
- Misses 21060 21065 +5
- Partials 1934 1935 +1 |
Python uses a rounding half to even strategy, which means that 1.5 and 2.5 both round to 2, which resulted inconsistency in the spot-count depending on whether there was an even or odd number of images.
Bugfixes -------- - ``dials.scale``: Fix crash when full-matrix minimisation is unsuccessful due to indeterminate normal equations. (#1653) - ``dials.scale``: Fix crash when no reflections remain after initial filtering. (#1654) - ``dials.export``: Fix error observed with ``format=mmcif`` for narrow sweeps with low symmetry (#1656) - Fix image numbering inconsistency in ascii histogram of per-image spot counts (#1660)
Bugfixes -------- - ``dials.scale``: Fix crash when full-matrix minimisation is unsuccessful due to indeterminate normal equations. (#1653) - ``dials.scale``: Fix crash when no reflections remain after initial filtering. (#1654) - ``dials.export``: Fix error observed with ``format=mmcif`` for narrow sweeps with low symmetry (#1656) - Fix image numbering inconsistency in ascii histogram of per-image spot counts (#1660) - ``dials.find_spots_server``: Significant performance improvement for HDF5 grid scans. (#1665)
Bugfixes -------- - ``dials.scale``: Fix crash when full-matrix minimisation is unsuccessful due to indeterminate normal equations. (#1653) - ``dials.scale``: Fix crash when no reflections remain after initial filtering. (#1654) - ``dials.export``: Fix error observed with ``format=mmcif`` for narrow sweeps with low symmetry (#1656) - Fix image numbering inconsistency in ascii histogram of per-image spot counts (#1660) - ``dials.find_spots_server``: Significant performance improvement for HDF5 grid scans. (#1665)
Python uses a rounding half to even strategy, which means that
1.5
and2.5
both round to2
, which resulted inconsistency in the spot-count depending on whether there was an even or odd number of images.