Skip to content

Commit

Permalink
Validate input
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeilstenedmands committed Jan 29, 2024
1 parent 8789fc4 commit 0f50c4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/dials/command_line/export_bitmaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ def imageset_as_bitmaps(imageset, params):
if params.imageset_index:
selected_images = []
for idx in params.imageset_index:
if idx > len(images):
sys.exit(
f"Bad value for imageset_index: {idx}. The imageset has length {len(images)}; allowable values for imageset_index are the range 1 to {len(images)} inclusive."
)
selected_images.append(images[idx - 1])
images = selected_images

Expand Down
5 changes: 5 additions & 0 deletions src/dials/util/export_bitmaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ def imageset_as_flex_image(
start = 1

# If the user specified an image range index, only export those
n_images = len(imageset)
for i_image in images:
if (i_image < start) or (i_image >= start + n_images):
raise ValueError(
f"Image {i_image} outside of scan range {start},{start+n_images-1}"
)
image = imageset.get_raw_data(i_image - start)

mask = imageset.get_mask(i_image - start)
Expand Down

0 comments on commit 0f50c4b

Please sign in to comment.