Skip to content
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

Fix ZeroDivisionError crash in dials.compute_delta_cchalf #1892

Merged
merged 5 commits into from
Oct 29, 2021

Conversation

jbeilstenedmands
Copy link
Contributor

When running the program on any single dataset, this results in crash and Traceback:

  File "/dials/build/../modules/dials/command_line/compute_delta_cchalf.py", line 139, in <module>
    run()
  File "/dials/conda_base/python.app/Contents/lib/python3.8/contextlib.py", line 75, in inner
    return func(*args, **kwds)
  File "/dials/build/../modules/dials/command_line/compute_delta_cchalf.py", line 134, in run
    script.run()
  File "/dials/modules/dials/algorithms/statistics/cc_half_algorithm.py", line 220, in run
    self.algorithm.run()
  File "/dials/modules/dials/algorithms/statistics/cc_half_algorithm.py", line 496, in run
    statistics.run()
  File "/dials/modules/dials/algorithms/statistics/delta_cchalf.py", line 259, in run
    self._cchalf = self._compute_cchalf_excluding_each_group()
  File "/dials/modules/dials/algorithms/statistics/delta_cchalf.py", line 300, in _compute_cchalf_excluding_each_group
    cchalf = compute_cchalf_from_reflection_sums(
  File "/dials/modules/dials/algorithms/statistics/delta_cchalf.py", line 152, in compute_cchalf_from_reflection_sums
    return compute_mean_cchalf_in_bins(bin_data)
  File "/dials/modules/dials/algorithms/statistics/delta_cchalf.py", line 127, in compute_mean_cchalf_in_bins
    mean_cchalf /= count
ZeroDivisionError: Please report this error to dials-support@lists.sourceforge.net: division by zero

This should not be reachable with proper input checking, so raise an error in initialisation if only one dataset/group is given.

@codecov
Copy link

codecov bot commented Oct 7, 2021

Codecov Report

Merging #1892 (ae0dbd1) into main (2751e2f) will increase coverage by 0.00%.
The diff coverage is 95.55%.

❗ Current head ae0dbd1 differs from pull request most recent head 170fa62. Consider uploading reports for the commit 170fa62 to get more accurate results

@@           Coverage Diff           @@
##             main    #1892   +/-   ##
=======================================
  Coverage   67.20%   67.21%           
=======================================
  Files         619      619           
  Lines       70014    70036   +22     
  Branches     9720     9722    +2     
=======================================
+ Hits        47054    47075   +21     
- Misses      20993    20995    +2     
+ Partials     1967     1966    -1     

@ndevenish ndevenish merged commit fab2987 into main Oct 29, 2021
@ndevenish ndevenish deleted the fix_deltacchalf_crash branch October 29, 2021 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants