Skip to content

Commit

Permalink
Added guards for Scans being None.
Browse files Browse the repository at this point in the history
  • Loading branch information
toastisme committed Mar 1, 2024
1 parent 611c6ed commit 2f6d79b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/dials/algorithms/centroid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def centroid_px_to_mm(detector, scan, position, variance, sd_error):

# Get the pixel to millimeter function
assert len(detector) == 1
if scan.has_property("time_of_flight"):
if scan is not None and scan.has_property("time_of_flight"):
return tof_centroid_px_to_mm_panel(
detector[0], scan, position, variance, sd_error
)
Expand All @@ -20,7 +20,7 @@ def centroid_px_to_mm_panel(panel, scan, position, variance, sd_error):
"""Convenience function to calculate centroid in mm/rad from px"""
# Get the pixel to millimeter function

if scan.has_property("time_of_flight"):
if scan is not None and scan.has_property("time_of_flight"):
return tof_centroid_px_to_mm_panel(panel, scan, position, variance, sd_error)

pixel_size = panel.get_pixel_size()
Expand Down Expand Up @@ -75,7 +75,7 @@ def centroid_px_to_mm_panel(panel, scan, position, variance, sd_error):

def tof_centroid_px_to_mm_panel(panel, scan, position, variance, sd_error):
"""Convenience function to calculate centroid in mm/tof from px"""
assert scan.has_property("time_of_flight")
assert scan is not None and scan.has_property("time_of_flight")

pixel_size = panel.get_pixel_size()
tof = scan.get_property("time_of_flight") # (usec)
Expand Down
2 changes: 2 additions & 0 deletions src/dials/algorithms/spot_finding/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ def from_parameters(params=None, experiments=None, is_stills=False):
# Setup the spot finder
contains_tof_experiments = False
for experiment in experiments:
if experiment.scan is None:
continue
if experiment.scan.has_property("time_of_flight"):
contains_tof_experiments = True
elif contains_tof_experiments:
Expand Down

0 comments on commit 2f6d79b

Please sign in to comment.